Hi, I'm trying to retrieve the unicode values of currency symbols from a database (we had lots of problems with locales so this is the way it's being done). In the database, the unicode representations eg \u20ac have been defined as Varchar2 but when they get into the Java layer, they appear as "\\u20ac". I have tried returning just the 20ac part & appending "\u" to it but JBuilder complains about illegal unicode escape characters. Anyone know how I can arrive at the equivalent of String x = "\u20ac" ?? Thanks
The reason JBuilder complains is that "\u" indicates the start of an escape sequence. It expects the unicode value after the 'u', but doesn't see it. There is a way to fix this so it will compile, but I doubt it will do anygood. Instead, I have a few questions:
1) Does your database support Unicode characters in a column with type VARCHAR?
2) If so, why don't you just store the single character rather than a string representation of the Unicode character? At the moment, as you can see, the database is storing the literal characters, not the unicode value.
3) If not, you could store it as an integral type and cast it to a char when you read it into your Java program. To me either of these solutions seems like less of a hassle than you current solution.
the code snip by eric seems the only likely way, unicodes are decoded at compile time, there's no way you can have a string "\u0012" with its unicode meaning at runtime- it wil just be a srting of 6 chars.
"It's not enough that we do our best; sometimes we have to do<br />what's required."<br /> <br />-- Sir Winston Churchill