'Valid Representation of unicode Sequence in Java
I have presto query that contains some Japanese characters in where clause
select col1 from xyz where col = '自社在庫' // example
for some reason i need to interpret this query and do some validations, for this i am using the facebook presto sql parser .
But when i use com.facebook.presto.sql.SqlFormatter.formatSql(sqlParsed, null);
The returned String looks like this :
SELECT col1 FROM xyz WHERE (colr = **U&'\81EA\793E\5728\5EAB'**)
Should it not convert it as select col1 from xyz where colr = '\u81EA\u793E\u5728\u5EAB'
Any way i can convert U&'\81EA\793E\5728\5EAB' back to '自社在庫' ?
Solution 1:[1]
It seems the presto serializer does something different than you expect. I'd try to search for a solution within the presto library.
If that does not work, you could translate the string by stripping off the leading and trailing asterisks, then replace every \
with \u
and are back to your assumed result.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Hiran Chaudhuri |