0

We open and read a file which has UTF 8 characters and prepare an image using the content read. But when we render that image to Browser we do not see the UTF8 characters instead we see some junk characters.

How can we make the image to be displayed with UTF 8 character format? Do we need to display or read in some specialized format?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Prakash
  • 69
  • 1
  • 1
  • 5
  • 2
    You need to be a lot more specific: How do you read the file? How do you "prepare an image" and how do you "render that image to Browser"? – Joachim Sauer Dec 03 '10 at 10:08
  • Which method do you use on the `Graphics` object (if you use it)? – dacwe Dec 03 '10 at 11:36
  • Here are the two threads for your reference: http://stackoverflow.com/questions/4285464/java2d-graphics-anti-aliased http://stackoverflow.com/questions/4316815/java2d-graphics-anti-aliased We basically read the UTF 8 characters from a file which has translated characters. Once the image is generated we are opening it in a browser. – Prakash Dec 03 '10 at 14:30
  • Have you verified that the `String` that you paint using Java2D acutally has the correct data in it. Maybe it's already butchered when you try to paint it. Where and how *exactly* do you read it from? – Joachim Sauer Dec 03 '10 at 15:28

1 Answers1

0

As we run the program on a Linux box we found that on Windows even it was causing issue. However when we changed the font type as "Dialog" we got the desired output:

Font font = new Font("Arial", Font.PLAIN, 11);  //old
Font font = new Font("Dialog", Font.PLAIN, 11); //new

Also we needed to convert UTF8 to Unicode.

But still we are unable to reach to the solution when we run the program on Linux box? Which font would support Chinese characters?

bluish
  • 26,356
  • 27
  • 122
  • 180
Programmer
  • 8,303
  • 23
  • 78
  • 162