社区
C#
帖子详情
Encoder和Encoding有什么区别啊?
d1223vg
2012-08-30 09:26:11
Encoder 类:
MSDN
,将一组字符转换为一个字节序列。
Encoding 类:
MSDN
,表示字符编码。
我知道Decoder是解码器
Encoder和Encoding有什么区别啊?实在搞不懂
Encoder和Encoding都有GetBytes方法,都是将一组字符编码到指定字节数组中
请指教啊
...全文
671
10
打赏
收藏
Encoder和Encoding有什么区别啊?
Encoder 类:MSDN,将一组字符转换为一个字节序列。 Encoding 类:MSDN,表示字符编码。 我知道Decoder是解码器 Encoder和Encoding有什么区别啊?实在搞不懂 Encoder和Encoding都有GetBytes方法,都是将一组字符编码到指定字节数组中 请指教啊
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
10 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
qldsrx
2012-08-30
打赏
举报
回复
难道我6楼的解释还不通俗吗?不要看什么连续块,只要看你是否要拆分。
就好比你发送一个文件,每次只发送1024字节而不是一次性发送整个文件大小,那么发送和接收就需要对这个大字符串(也叫连续块)拆分了处理,不拆没事,一拆就出问题了,编码是需要整体考虑才是正常编码,如果一个2字节编码的汉字被拆开两个字节单独处理,那还是汉字吗?
d1223vg
2012-08-30
打赏
举报
回复
Encoder类和Encoding类是不是都可以作为编码器?都可以把所有字符编码为一个字节序列,是吗?
那........................还是很模糊,
连续块的编码,就用Encoder类吗?
什么是连续的块?
qldsrx
2012-08-30
打赏
举报
回复
说得更通俗点,当一个汉字用2个字节表示的时候,你收到9个字节,那么只可能包含4个汉字,最后一个字节只有半个汉字,那么这半个汉字如何处理?这里就需要合并到下次处理过程中。
对于UTF8编码这种不定长的编码规则是最有意义的,因为不定长编码,结尾处很可能被拆分。
qldsrx
2012-08-30
打赏
举报
回复
请看这里,这是一个派生类的说明,比基类的详细:
http://msdn.microsoft.com/zh-cn/library/system.text.utf8encoding.getencoder.aspx
备注部分说明了它的使用场合,它主要用在不连续的编码或解码中,当数据量过大,或者网络传输中尚未收到全部数据就开始处理是,用这个方法得到Encoder 类或Decoder类,比直接使用Encoding 要好,因为前者维护了数据块结尾的信息,用在下次编码操作中。
d1223vg
2012-08-30
打赏
举报
回复
[Quote=引用 2 楼 的回复:]
你给的MSDN足够说明了两者的关系了,请看这里:
若要获取 Encoder 类某个实现的实例,应用程序应当使用 Encoding 实现的 GetEncoder 方法。
可见,一般不直接使用Encoder 类,而是通过Encoding 来获取具体编码规则的Encoder类,或者直接通过Encoding 类操作,否则你不能控制字符编码。
[/Quote]
是啊,我知道Encoding 来获取具体编码规则的Encoder类实例。
http://msdn.microsoft.com/zh-cn/library/system.text.encoding.aspx
这个地方有这么一截话:
如果要转换的数据仅存在于连续块(如从流中读取的数据)中,或者如果数据量很大,需要划分为较小的块,则应用程序应当使用由某个派生类的 GetDecoder 方法提供的 Decoder 或由该派生类的 GetEncoder 方法提供的 Encoder。
请帮忙理解一下这截话,我不太能理解....也许玄机就在这里面
杰拉尔
2012-08-30
打赏
举报
回复
第一两个是不同的class
不同class中方法是可以重命名的
new Encoding().GetBytes();
new Encoder.GetBytes()
虽然方法相同名可参数确不一样 如果一样要这两个一样的方法做什么微软不会写这种没用代码。
Encoding还有.UTF8这样的静态 方法来获取指定编码格式字符串转换的BTYE[]
qldsrx
2012-08-30
打赏
举报
回复
你给的MSDN足够说明了两者的关系了,请看这里:
若要获取 Encoder 类某个实现的实例,应用程序应当使用 Encoding 实现的 GetEncoder 方法。
可见,一般不直接使用Encoder 类,而是通过Encoding 来获取具体编码规则的Encoder类,或者直接通过Encoding 类操作,否则你不能控制字符编码。
bdmh
2012-08-30
打赏
举报
回复
帮助中说的,应该可以理解吧
在派生类中重写时,获取一个解码器,该解码器将 Unicode 字符序列转换为已编码的字节序列。
Encoder..::.GetBytes 方法将连续的字符块转换为连续的字节块,采用的方式类似于该类的 GetBytes 方法。但是,Encoder 在调用之间维护状态信息,因此它可以正确地对跨块的字符序列进行编码。Encoder 还保留数据块结尾的尾部字符并将这些尾部字符用在下一次编码操作中。例如,一个数据块的末尾可能是一个不匹配的高代理项,而与其匹配的低代理项则可能位于下一个数据块中。因此,GetDecoder 和 GetEncoder 在网络传输和文件操作中很有用,这是因为这些操作通常处理数据块而不是完整的数据流。
给实现者的说明:
默认实现返回一个 Encoder,它调用当前 Encoding 的 GetByteCount 和 GetBytes 方法。您的应用程序必须重写此方法以返回在调用之间维护其状态的 Encoder。
小志
2012-08-30
打赏
举报
回复
http://www.cnblogs.com/criedshy/archive/2012/08/08/2628554.html
mini JPEG
encode
r
JPEG
encode
r, 非常小,也很快,适用于embedded application。我已经成功的port到了ARM9上。我的项目是一个scanner,用这个
encode
r可以实时的用ARM9进行jpeg
encoding
A Simple JPEG
Encode
r in C#
JPEG is one of the most widely used standards for
encoding
photographs, pictures, or other visual content. But, the internal workings are mostly overlooked. We are used to using image.Save("filename",Imaging.ImageFormat.Jpeg);, but what's going inside image.save(); remains a big mystery for the programmer. Most of the available implementations of JPEG
Encode
r/Decoder are in C/C++. But, for a project, my friend 'anirban' required a JPEG
encode
r in C#. So, we started writing our own
encode
r. It turned out to be very complex and difficult. The one we wrote from scratch was really-really slow.. some functions had fourth order complexity (mostly the DCT part). Somehow, we managed to get some 'C' code from a forum. I converted parts of the 'C' code to C#; it was tedious work, but it worked pretty fast due to the fast DCT (AA&N).
GPT-3-
Encode
r:适用于GPT-2 GPT-3的Javascript BPE编码解码器
适用于GPT-2 / GPT-3的GPT-3-
Encode
r Javascript BPE编码解码器 关于 GPT-2和GPT-3使用字节对编码将文本转换为一系列整数以输入模型。 这是OpenAI原始python编码器/解码器的javascript实现,可在找到 用npm安装 npm install gpt-3-
encode
r 用法 兼容Node> = 12 const {
encode
, decode} = require('gpt-3-
encode
r') const str = 'This is an example sentence to try
encoding
out on!' const
encode
d =
encode
(str) console.log('
Encode
d this string looks like: ',
encode
d) console.log('We
owasp-java-
encode
r:OWASP Java编码器是Java 1.5+的易于使用的嵌入式高性能编码器类,没有依赖关系,而且负担很轻。 该项目将帮助Java Web开发人员防御跨站点脚本!
OWASP Java编码器项目 上下文输出编码是停止跨站点脚本编写所必需的计算机编程技术。 该项目是Java 1.5+易于使用的嵌入式高性能编码器类,几乎没有负担。 开始使用OWASP Java编码器 您可以从下载JAR。 JSP标签和EL函数可在
encode
r-jsp中使用,也可以在。 这些罐子也可以在Maven中使用: < dependency> < groupId>org.owasp.
encode
r groupId> < artifactId>
encode
r artifactId> < version>1.2.3 version> dependency> < dependency> < groupId>org.owasp.
encode
r groupId> < artifactId>encod
mp3.rar_As One_GIVE_matlab vlc_mp3
encode
r_mp3
encode
r matlab
it is mp3 MPEg2 Video
Encode
r, Only I frames currently
encode
d. The
encode
d files can be played using any player i used vlc player. As usual some 1. Use one test.avi file, preferrable 128 x 128 size, you can download http://support.microsoft.com/kb/119383 2. This is just the initial code, updates are likely to happen. One can use this code just for initial study purposes, for example bit stream packing, basic of video etc. Will further modify this for P frame
encoding
and will make a simple Profile. If you happen to use this code and update for P frames please give the link. Running: 1. Open main_video_enc.m, use the test file to be
encode
d. 2.
Encode
d file will be test.m2v. Play using vlcplayer. 3. Only 15 frames are
encode
d currently modify the index to increase.
C#
111,098
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章