Link to home
Start Free TrialLog in
Avatar of yysasa
yysasa

asked on

How to convert an UTF-8 String to Big5 String

Anyone knows how to convert an UTF-8 String to Big5 String?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yysasa
yysasa

ASKER

I tried the following code (strUTF8 contains UTF-8 characters):
String s = new String(strUTF8.getBytes(), "UTF-8");
byte[] big5bytes = s.getBytes("Big5");
String strResult = new String(big5bytes, "Big5");

but the strResult is not in Big5 format, why?
>>but the strResult is not in Big5 format, why?

How are you determining this? For instance, if you're viewing the result in a Windows console, it won't support that encoding
Try to view it with a Swing component with its Font set to one that supports Big5 characters
>>but the strResult is not in Big5 format, why?

Why did you post that comment after using the same code principle as in the comment you marked as the answer?