Home > Net >  Valid Representation of unicode Sequence in Java
Valid Representation of unicode Sequence in Java

Time:02-10

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 '自社在庫' ?

CodePudding user response:

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.

  •  Tags:  
  • Related