views:

194

answers:

2

i m using postgre database it has encoding UTF-8 in that unicode for marathi word pimpri is like this \u092A\u093F\u0902\u092A\u0930\u0940 \u0935\u093E\u0918\u0947\u0930\u0947

and when at client side i wrote a code String tempString=Strings.toEscapedUnicode(strQueryString[1]); it generate unicode like this u00E0\u00A4\u00AA\u00E0\u00A4\u00BF\u00E0\u00A4\u00AA\u00E0\u00A4\u0082\u00E0\u00A4\u00B0\u00E0\u00A5\u0080

so i have problem for matching it.

i have problem that how to recognize in which formate is? u00E0\u00A4\u00AA\u00E0\u00A4\u00BF\u00E0\u00A4\u00AA\u00E0\u00A4\u0082\u00E0\u00A4\u00B0\u00E0\u00A5\u0080 is this in utf8 or utf16 or utf32

and also how to convert utf8 to utf16 using java is there any method for that???

+1  A: 

The data in your database appears to be UTF-16.

But your client code appears to be UTF-8. Looking at your data, the first character (DEVANAGARI LETTER PA) which is \u092A in UTF-16 and 0xE0 0xA4 0xAA in UTF-8.

In Java, you can convert your string to the byte sequence for a specific encoding using one of the getBytes overload.

R Samuel Klatchko
+1  A: 

Why do you have to handle with the encoding? The PostgreSQL JDBC driver should handle it, Java uses UTF-16 internally. So you can simply compare the string got by ResultSet.getString() with any other string or pass any string as parameter if using PreparedStatement.setString().

Arne Burmeister