Reputation: 1177
I am displaying simplified chines character retrieved from database using the below code snippet but it is displaying junk character
String text="×°ÏäʱÇëÅÄÕÕ"; // retrieved from database
String result=new String(text.getBytes("utf-8"),"GB2312");
Actual output is : �掳�盲�卤�毛����
Expected Output is : 装箱时请拍照
please help
Upvotes: 1
Views: 1366
Reputation: 43728
A string always should have the correct characters. Only during conversion to a byte stream the encoding comes into play.
So when text
is what you got from the DB then you have the problem already in fetching the string from the DB.
Upvotes: 2