简体   繁体   中英

Java Unicode characters to UTF

在Java中,如何将包含转义的Unicode字符的字符串转换为utf 8,例如从Rüppell's_Vulture转换为R%c3%bcppell's_Vulture

String s = URLDecoder.decode("R%c3%bcppell's_Vulture", "UTF-8");
String s = URLEncoder.encode("Rüppell's_Vulture", "UTF-8");

With % it is an URL encoding.

Copy it to byte array with getBytes("UTF-8). Like this:

byte[] utf = String.getBytes("UTF-8")

Do not know the way of dealing with it just with Strings (I believe they have fixed encoding).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM