Results 1 to 3 of 3
  1. #1
    flywheel's Avatar
    flywheel is offline Member
    Join Date
    Sep 2008
    Posts
    8
    Rep Power
    0

    Thumbs up [SOLVED] Codepage conversion

    Hello

    I'm working on this little program that retrieves a html-page using the URL and BufferedReader.
    But I'm having some problems with special characters like '' with some pages.
    My own guess is that the reason is that it is a ISO-8859-1 page loaded into a UTF-8 stream. But is it possible to perform a conversion of the retrieved string ?

    Live long and prosper...
    Last edited by flywheel; 02-09-2009 at 05:56 PM. Reason: Sufficient input to fix problem achieved

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    Look at CharsetDecoder and ByteBuffer. The Java network I/O classes make use of these to handle conversions from code page data to Unicode. Of course, you are expected to know in which code page the bytes are encoded. They also offer replacement options for unknown characters.

    This means you will have to read the data at the byte level, not as characters. ByteBuffer is a thin wrapper class, so once you have the bytes in an array, creating a ByteBuffer around the array is simple and low overhead.

    This is obviously a different approach. I hope this helps...

  3. #3
    flywheel's Avatar
    flywheel is offline Member
    Join Date
    Sep 2008
    Posts
    8
    Rep Power
    0

    Talking

    It sure does Steve11235 - many thanks, I'll go and do some experimenting :D

Similar Threads

  1. XLS to PDF conversion
    By nitin2k2k in forum Advanced Java
    Replies: 18
    Last Post: 07-02-2013, 11:17 AM
  2. Doc to Pdf conversion
    By praveen.kb in forum Advanced Java
    Replies: 2
    Last Post: 01-16-2009, 12:27 PM
  3. Word to xml Conversion
    By kushagra in forum Advanced Java
    Replies: 3
    Last Post: 10-16-2008, 08:23 AM
  4. Conversion from wav to vox
    By bozovilla in forum Advanced Java
    Replies: 1
    Last Post: 07-31-2008, 05:54 AM
  5. Text to XML conversion
    By tarandeep.singh in forum XML
    Replies: 1
    Last Post: 06-14-2008, 02:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •