The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'.
Exception when executing
if (br.PeekChar() != -)
br is a binary reader.
The data to peak is D000 (D0=208)
The cause is, for PeekChar, after peak, the value will be transformed to char.
But Unicode and normal char has different length.
If I use br.ReadByte(), there will be no problem.
But if it hit the end of one file, br.ReadByte() would threw an error.
I googled and found many similar errors.
The best article that solved my problem is
Use the following to identify a file end and don't use PeekChar().
if(reader.BaseStream.Position == reader.BaseStream.Length)
or exclaim the Encoding format. Then PeekChar will be OK to use.
BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.ASCII);
I used the second one. problem solved.
The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'.的更多相关文章
- c#有关udp可靠传输(包传输数据包) 升级
在c#有关udp可靠传输(包传输数据包)我们讨论,UDP包的发送,可是上一个程序有一个问题.就是数据比較大.一个Message类序列化后都有2048B,而实际的数据量也就只是 50B罢了,这就说明当中 ...
- 自动判断文本文件编码来读取文本文件内容(.net版本和java版本)
.net版本 using System; using System.IO; using System.Text; namespace G2.Common { /// <summary> / ...
- c#基于事件模型的UDP通讯框架(适用于网络包编解码)
之前写过一篇关于c#udp分包发送的文章 这篇文章里面介绍的方法是一种实现,可是存在一个缺点就是一个对象序列化后会增大非常多.不利于在网络中的传输. 我们在网络中的传输是须要尽可能的减小传送的数据包的 ...
- 《C与指针》第十五章练习
本章例程 15.1打开和关闭文件 #include <stdlib.h> #include <stdio.h> int main(int ac, char **av) { in ...
- Java程序员的日常—— IOUtils总结
以前写文件的复制很麻烦,需要各种输入流,然后读取line,输出到输出流...其实apache.commons.io里面提供了输入流输出流的常用工具方法,非常方便.下面就结合源码,看看IOUTils都有 ...
- 文件输入输出流工具: IOUtils使用总结
序言 以前写文件的复制很麻烦,需要各种输入流,然后读取line,输出到输出流...其实apache.commons.io里面提供了输入流输出流的常用工具方法,非常方便.下面就结合源码,看看IOUTil ...
- P4705 玩游戏
思路 超级麻烦... 写了一堆最后常数太大T飞了... 真的难受 发现solve函数可以不用把下一层复制上来,直接传指针就可以,下次再说写不写叭 思路 \[ ans_k=\sum_{i=1}^n\su ...
- csharp:FTP Client Library using FtpWebRequest or Sockets
https://netftp.codeplex.com/SourceControl/latest http://ftplib.codeplex.com/ https://www.codeproject ...
- IOUtils总结
参考:https://www.cnblogs.com/xing901022/p/5978989.html 常用的静态变量 在IOUtils中还是有很多常用的一些变量的,比如换行符等等 public s ...
随机推荐
- focus on these tools
http://www.oschina.net/p/dubbo http://www.blogjava.net/hispark/archive/2008/12/01/243310.html http:/ ...
- Programme skills
1. Dynamic library 2. Template class. function template<typename T> classs Sample { ... templa ...
- logstash multiline 把文件处理为单个 event
需求 多个文本文件需要存到 ES 中去. 每一个文件存放为一个 doc. 每一个文件都是多行的,行数不定,且没有固定的内容格式. update time: Mon Jun :: CST package ...
- C++获取文件长度
ifstream fin("example.txt", ios::binary); fin.seekg(0, ios::end); // 设置指针到文件流尾部 streampos ...
- Executor 和Executors
Java里面线程池的顶级接口是Executor,但是严格意义上讲Executor并不是一个线程池,而只是一个执行线程的工具.真正的线程池接口是ExecutorService. 下面这张图完整描述了线程 ...
- jquery easyui combobox 级联及触发事件,combobox级联
jquery easyui combobox 级联及触发事件,combobox级联 >>>>>>>>>>>>>>&g ...
- CentOS 7.x安装ELK(Elasticsearch+Logstash+Kibana)
第一次听到ELK,是新浪的@ARGV 介绍内部使用ELK的情况和场景,当时触动很大,原来有那么方便的方式来收集日志和展现,有了这样的工具,你干完坏事,删除日志,就已经没啥作用了. 很多企业都表示出他们 ...
- BSP模型
http://www.uml.org.cn/yunjisuan/201212191.asp Hama中最关键的就是BSP(Bulk Synchronous Parallel-"大型" ...
- [转] sql数据类型 varchar与nvarchar的区别
SQL Server提供两种数据类型来存储字符信息.在如何在SQL Server或应用程序中使用方面,这两种数据类型大致是一样的.差别在于nvarchar是用于存储处理数据库图表中多语言数据的Unic ...
- Java多线程编程总结(学习博客)
Java多线程编程总结:网址:http://lavasoft.blog.51cto.com/62575/27069/