javaMan
javaMan

Reputation: 6680

Japanese fonts not getting displayed properly when running on Unix box

I have a Spring MVC based Java webapp. I have some data to be displayed in Japanese fonts. I did some online research and noticed that UTF-8 is the charset encoding I need. I added the below line into my app. All it does is adds charset encoding to response header.

 response.setCharacterEncoding("UTF-8");

When I test on Windows 7 Japanese fonts are showing up properly.

when I ran the same war file on a Unix box, I see only these characters: ��� and numbers if any . I checked the response header in Chrome Debugger and I still see UTF-8 encoding.

The only difference i see in header information is windows has server as Apache-Coyote/1.1 while the one on unix has apache.

Can some suggest what else I need to check?

Upvotes: 1

Views: 1255

Answers (1)

Charles Forsythe
Charles Forsythe

Reputation: 1861

The problem might be how the string is created. Is it read from a file?

If so, the file itself has an encoding and you are likely reading it in according to the default platform encoding. If the file is in one encoding, but you read it in another, the text in your String will be incorrect to begin with.

A quick check using debugging/logging is the length of the String. If it reports one length on Windows and another on Unix, then there is probably an encoding error while generating the string. An example is when a character in UTF-8 is interpreted as ISO-8859, and you see something like this: –

In this case, you would expect the String to have a length of 1, but it has a length of 3. If that was embedded in some other text, you would see a difference of 2 in the lengths, even though the text should be the same.

Upvotes: 2

Related Questions