0

I've got a TextView in my app to put my data obtained from scraping. the data is some chinese words (unicode), the view shows the unicode instead of these chinese words.

I've find out the problem is caused by "\uxxxx" and "\uxxxx". The system return the value of "\uxxxx".

The chinese words can be show if I hard code the string pass into it, for example

Title.setText("\u4F60\u597D\u55CE");
\\ the chinese words can show properly as "你好嗎"

Title.setText("\\u4F60\\u597D\\u55CE");
\\ the words show as "\u4F60\u597D\u55CE"

I try to compare the different:

Log.i("setTitle", String.valueOf(Title.equals("\u4F60\u597D\u55CE")));
//returned false but should be true


Log.i("setTitle", String.valueOf(Title.equals("\\u4F60\\u597D\\u55CE")));
//returned true but should be false

I've tried

Title.replace("\\\\u","\\u");
Title.replace("\\\\","\\");

these all provides the same result in my comparison code

I've even tried

Title.replace("\\","").replace("u", "\\u")

I still cannot get the result I want.

Just want to ask is there any way I can show chinese character with unicode in TextView.setText()?

Neo Luk
  • 446
  • 4
  • 10

1 Answers1

0

Just replace all \\u with \u before setting it to the Textview and that should work.

Bhavin Desai
  • 220
  • 2
  • 9