Goltsev Eugene
Goltsev Eugene

Reputation: 3627

Unicode string in Java (Android) not working

I'm making next record in order to compare entered chars with this array:

 String[] GSM_7_BIT_EXT = {"\u000c", "\u005e", "\u007b", "\u007d", "\u005c", "\u005b", "\u007e", "\u005d", "\u007c", "\u20ac"};


After compile (Android Studio) getting lot of mistakes, like:
- '}' expected
- illegal character: \35
- expected
and many others.

What am I doing wrong?

Upvotes: 2

Views: 4287

Answers (1)

wero
wero

Reputation: 32980

The culprit is \u005c: This is the backslash character, therefore "\u005c" is equal to "\" which is not a valid string literal. (Test this by removing "\u005c" from the array definition).

You could write "\\" instead.

Upvotes: 5

Related Questions