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 ...
随机推荐
- uiatuomator如何调试
博主较笨,在使用junit 和uiatuomator结合时不知道怎么调试,因为uiatuomator一直是push在手机上,而junit是需要代码运行的,那我该怎么办,现在发一下不知道是哪位大神写的代 ...
- scala学习笔记:match表达式
写了一个超级长的表达式,估计不是最简洁的: scala> def foo(ch:Any)=ch match { case true=>"male";case false ...
- 可发布指定的ASP.NET页面的插件:LimusicAddin
涉及到的技术点 VS插件开发.推荐阅读:Visual Studio 2008 可扩展性开发 asp.net 预编译.使用aspnet_comlier.exe(在目录:C:\Windows\Micros ...
- ###《Effective STL》--Chapter4
点击查看Evernote原文. #@author: gr #@date: 2014-09-14 #@email: forgerui@gmail.com Chapter4 迭代器 Topic 26: i ...
- iOS启动图片适配问题
Portrait 是竖屏 top home button Landscape是横屏 left home button retina 要求640x1136pixels, 在右边的Image属性 Expe ...
- ZOJ 1202 Divide and Count(排列组合)
Divide and Count 题目大意:给定箱子的数量和每个箱子的容量,在每个箱子里都装满对应容量的宝石,每颗宝石都是独一无二的,求一共有多少种放置方式.但是如果两个箱子的容量相同,则认为是 同一 ...
- HDU 4764 Stone(博弈)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4764 题目大意:Tang和Jiang玩石子游戏,给定n个石子,每次取[1,k]个石子,最先取完的人失败 ...
- 删除Windows 文本右键选项
删除Windows 文本右键选项 在Windows上用所谓的绿色版安装了EditPlus,但是给的卸载程序(即删除掉注册表相应的选项)无法使用,导致只能手动从Regedit(注册表-编辑器)中手动删除 ...
- 把十进制整数转换为r(r=2)进制输出(顺序栈实现)
上周的第二个作业补上~~ 上周的要求: 1.给出顺序栈的存储结构定义. 2.完成顺序栈的基本操作函数. 1) 初始化顺序栈 2) 实现入栈和出栈操作 3) 实现取栈顶元素 ...
- OpenJudge 2810(1543) 完美立方 / Poj 1543 Perfect Cubes
1.链接地址: http://bailian.openjudge.cn/practice/2810/ http://bailian.openjudge.cn/practice/1543/ http:/ ...