0
A
回答
1
你输入的字符串不是ASCII而是一个URL编码的字符串。
可以像这样它进行解码:
String s = "Fa%C3%A7ade";
System.out.println(URLDecoder.decode(s, "UTF-8"));
Java中的String
被表示为字符阵列(char[]
),它不以任何编码进行编码。当String
转换为字节数组或字节数组转换为String
时,编码起作用。
所以,如果你有一个字节数组是使用UTF-8编码的一个String
,你可以将其转换为String
这样的:
byte[] arr = {104, 101, 108, 108, 111};
String s = new String(arr, StandardCharsets.UTF_8);
System.out.println(s); // Prints "hello"
// Or your input string would be:
arr = {70, 97, -61, -89, 97, 100, 101};
s = new String(arr, StandardCharsets.UTF_8);
System.out.println(s); // Prints "Façade"
+0
谢谢!你是对的 – user21399 2014-09-02 07:50:02
0
如何
new String (bytes, "UTF-8");
0
使用阿帕奇公地编解码器
byte[] bytes = StringUtils.getBytesUtf8(asciiString);
String utfString = new String(bytes);
相关问题
- 1. iPhone - 从WindowsCP1251转换NSString编码为UTF8
- 2. 转换ASCII到UTF8编码
- 3. 将utf8代码点字符串转换为utf8 <U+0161>转换为utf8
- 4. 将txt文件编码从DOS737转换为UTF8
- 5. 转换重音UTF8编码使用PHP
- 6. 无法转换UTF8编码HttpResponseMessage
- 7. 编码URL UTF8 - 壳脚本
- 8. JSON数据转换为编码的URL
- 9. 将JavaScript数组转换为URL编码
- 10. 从本地编码转换C字符串以UTF8
- 11. Python将html ascii编码的文本转换为utf8
- 12. C#:将byte []转换为UTF8编码的字符串
- 13. 在Python中使用UTF8编码的JSON转换为CSV
- 14. 如何将K12中的win1251编码转换为UTF8?
- 15. MySQL将表格从Latin1转换为utf8
- 16. 无法从UTF8转换为ASCII
- 17. 从UTF8转换为Java中的ASCII
- 18. 从UTF8到ASCII的转换
- 19. 转换KOI8-R为utf8
- 20. 转换数据库为utf8
- 21. 将Unicode转换为UTF8
- 22. 将UTF8转换为Windows-1252
- 23. ios UTF8编码从nsstring
- 24. Python的编码ISO为utf8
- 25. utf8编码的URL在轨道2.3.4
- 26. UTF8转换
- 27. VHDL编码..从整数转换为bit_vector
- 28. C++ UTF8编码
- 29. utf8和编码
- 30. C#UTF8编码
icza是正确的,你的投入不是ASCII和有不需要将ASCII转换为UTF-8,因为它是一个子集。 – 2014-09-02 07:40:02