Arun
Arun

Reputation: 1177

character encoding issue - GB2312

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

Answers (1)

Henry
Henry

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

Related Questions