4

I have an application that stores data in UTF-16 (mainly because the of the Chinese/Big-5 characters). It uses Google Protocol Buffers for the request/response protocol. I realize you can't send UTF-16 data back in the string format. I was trying to send the data back in a bytes data type through the protocol and have the client read the byte data in and create a UTF-16 string.

Is this the best way to go about this?

Has anyone ran into anything like this before?

Is there a way i can convert UTF-8 data to UTF-16 using the string data type?

user2884282
  • 59
  • 1
  • 5

1 Answers1

1

if you are already having a valid UTF-8 string, why not try

string = new String(string.getBytes("UTF-8"), "UTF-16");

I assume you can use java.

jester
  • 3,491
  • 19
  • 30