I'm trying to encode a string into utf-8 and I want the result as a String, is there a way to easily get it?
Asked
Active
Viewed 8,621 times
1
-
I would suggest the second solution provided in (https://stackoverflow.com/questions/5729806/encode-string-to-utf-8) – Ishnark May 24 '17 at 14:35
1 Answers
0
The only thing that has an encoding is a Byte array PLUS encoding. So if you need UTF-8 data, then you need a byte[] PLUS encoding.
See more here
Or just do:
Charset.forName("UTF-8").encode(myString)
Or
byte[] ptext = String.getBytes("UTF-8");
All in same question

developer_hatch
- 15,898
- 3
- 42
- 75