The procedure is simple...
First implement the interface nsICharsetDetectionObserver in the class where you
want the detected charset to be notified.
The interface just need to implement one function Notify(). This function will b
e called and the final result will be passed whenever the engine positively iden
tifies a charset.
package org.mozilla.intl.chardet ;
import java.lang.* ;
public interface nsICharsetDetectionObserver {
public void Notify(String charset) ;
}
Second, initialize the class nsDetector. If you find a non-ascii character
in your stream then start feeding data to the DoIt() member funtion.
Finally, once you are done with the input streeam, call DataEnd().
By this time the engine should have notified the detected charset.
See src/HtmlCharsetDetector.java for sample implementation.