user936580 user936580 - 1 year ago 208
Java Question

Invalid character constant in a UTF-8 character

I'm trying to assign 'o͝' (a phonetic character) to a Character in a Java program, but I get the error "Invalid character constant". My file is using UTF-8 and other phonetic characters work ok, but not this one. It looks as if this character is, in fact, two (an 'o' and a ligature or something like that), but I can not break it is forming parts.

Code example:

Character test = 'o͝';

Any help would be appreciated.

Answer Source

The glyph is called "small letter o with combining double breve" and can, in source, be written as;

String a = "\u006f\u035d";

Since it is a combining character (ie two characters), the resulting value cannot be assigned to a single Java char, you'll need to use a String.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download