Menu

encoding change from ISO-8859-1 to Big5

Help
2005-01-11
2013-04-27
  • mikeliu1976

    mikeliu1976 - 2005-01-11

    regards:

    I use htmlparser http://htmlparser.sourceforge.net/javadoc/index.html
    to parse existing File test.htm
    and output to test2.txt.

    "javac ToHtmlDemo" is ok.
    but when
    "java ToHtmlDemo"

    exception say
    encoding change from ISO-8859-1 to Big5
    ----------------------------------
    Do I miss something important?
    thank you
    may god be with you

    Followings is my code.

    import org.htmlparser.Parser;
    import org.htmlparser.util.NodeIterator;
    import org.htmlparser.util.ParserException;
    import java.io.*;

    public class ToHtmlDemo
    {
        public static void main (String[] args) throws ParserException
        {
           // PrintWriter out= new PrintWriter(); 
          try{
          
            FileOutputStream htmlparserOutput = new FileOutputStream("test2.txt");       
            PrintWriter out=null;
            out = new PrintWriter(htmlparserOutput);
            Parser parser = new Parser ("test.htm");
            //StringBuffer html = new StringBuffer (4096);
            for (NodeIterator i = parser.elements();i.hasMoreNodes();){
           // out.print (list.elementAt(i).toHtml ());    
           // html.append
            out.print(i.nextNode().toHtml ());}
           
           // System.out.println (html);
           
            out.close();
            htmlparserOutput.close();
         }
            catch(IOException e)
       {
         }
           // test2.close();
                   
        }
    }

     
    • Derrick Oswald

      Derrick Oswald - 2005-01-11

      try setting the encoding before starting the parse:

              Parser parser = new Parser ("test.htm");
      -->    parser.setEncoding ("Big5");
              //StringBuffer html = new StringBuffer (4096);

       
    • mikeliu1976

      mikeliu1976 - 2005-01-12

      regards:

      It test ok.

      thank you all
      May god be with you all

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.