zhaocong
zhaocong

Reputation: 334

How to print unicode string as it is in Java?

I would like to debug emoji icon issue for Android development. My application reads text message from remote server.

String test = String.format("%s",unicodeStr);
Log.i("xxx",test);

I expect it prints something like “\u23434", however it prints "".

So my question is, how could I print out the unicode string as it is?

Thanks a lot.

Upvotes: 0

Views: 5574

Answers (2)

zhaocong
zhaocong

Reputation: 334

I find an another solution to solve the problem now

for (char curr : str.toCharArray()){
   //print out the character or do whatever you wanna have
   int code = curr;
   Log.i("tag",String.format("%x",code));
}

Upvotes: 1

Achintya Jha
Achintya Jha

Reputation: 12843

String s = "\\u23434";
System.out.println(s);

It prints unicode String as it is.

Upvotes: 2

Related Questions