简体   繁体   English

如何从输入流中读取Java字节范围之外的有效utf-8字符0xC2 0x85?

[英]How can i read valid utf-8 characters 0xC2 0x85 from an input stream which are outside the byte range in java?

I have an input stream that contains valid utf8 characters 0xC2 0x85 (U+0085). 我有一个输入流,其中包含有效的utf8字符0xC2 0x85(U + 0085)。 How can I read and print this correctly in java? 如何在Java中正确读取和打印此内容? using byte array doesn't help i think as 0x85 is out of range. 使用字节数组无济于事,我认为0x85超出范围。 Basically, I need to read utf8 characters coming from a socket in java which contains 0xC2 0x85 基本上,我需要读取来自Java中包含0xC2 0x85的套接字的utf8字符

If you have a valid stream in UTF-8 (is) then use 如果您在UTF-8(是)中拥有有效的流,请使用

   Reader rdr = new InputStreamReader(is, "UTF-8");

this will convert UTF-8 bytes into Java chars 这会将UTF-8字节转换为Java字符

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让System.in输入流读取utf-8字符? - How can I make System.in Input Stream read utf-8 characters? 如何在Java中替换/删除UTF-8字符串中的4(+)字节字符? - How to replace/remove 4(+)-byte characters from a UTF-8 string in Java? 如何解决InputStream LeftoverDataException:记录0x85的初始化还剩下18个字节需要读取 - How to resolve InputStream LeftoverDataException : Initialisation of record 0x85 left 18 bytes remaining still to be read 转换汉字时Java桥代码错误:'utf-8'编解码器无法解码位置0的字节0xc0:无效的起始字节 - Java bridge code error while converting chinese characters : 'utf-8' codec can't decode byte 0xc0 in position 0: invalid start byte 我如何将Java Regex用于土耳其语字符到UTF-8 - How I can use Java Regex for Turkish characters to UTF-8 从System.in流中读取和写入UTF-8字符 - Read and Write UTF-8 characters from System.in stream 一个21字节的UTF-8序列如何仅来自5个字符? - How can a 21 byte UTF-8 sequence come from just 5 characters? 如何使用Java方法Class.getResourceAsStream()从jar中读取UTF-8文本文件? - How can I read a UTF-8 text file from a jar using the Java method Class.getResourceAsStream()? 如何在不将字符转换为 Java 中转义的 unicode 字符的情况下保存 UTF-8 文件? - How can I save UTF-8 files without converting characters to escaped unicode characters in Java? 如何将字节流转换为UTF-8字符? - How to convert stream of bytes to UTF-8 characters?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM