lordkian
lordkian

Reputation: 95

Unknown character android

I'am working on an android project (Farsi is supported) and I had an error so I scanned char by char. then I saw '' with ASCII code 8204 (it's utf8 by ASCII I mean cast to int) at the end of string.
P.N. item.trim() (type of item is String) didn't remove it.
first what is this? and second how to get rid of it?

Upvotes: 0

Views: 411

Answers (1)

Tom Blodget
Tom Blodget

Reputation: 20812

8204 decimal is 200C hexadecimal. 0x200C is a valid UTF-16 code unit sequenece for U+200C, which is a Unicode codepoint: ZERO WIDTH NON-JOINER. Java's Character.isWhitespace(int codePoint) says that it is not whitespace. Therefore, trim would not remove it.

You can use some other way, such as replace all such characters ("\u200C") with the empty string or removing just ones at the end of the string.

[Please don't say ASCII unless a specification calls it out. As you can see, Java doesn't generally use ASCII.]

Upvotes: 1

Related Questions