创建自己的编码 [英] Create own encoding
问题描述
如何在Ruby(1.9)中创建自己的编码?编码将用于在从文件读取/写入时转换字符串,即通常用于处理非标准编码字符串中的数据( http://en.wikipedia.org/wiki/Mazovia_encoding )
How can I create my own encoding in Ruby (1.9)? The encoding would be for converting string while reading/writing from/for a file, i.e. generally for manipulating data in nonstandard encoded strings ( http://en.wikipedia.org/wiki/Mazovia_encoding )
推荐答案
我无法在ruby-docs中找到关于使用专有编码的任何引用,而 Encoding
类没有任何初始化器(但是 Encoding.find()
可以加载一些编码 IConv
动态支持)不幸的是afaik Mazovia
即使在 iconv
,所以你不得不执行自己的课程...
I couldn't find any references in the ruby-docs about using proprietary encodings, and the Encoding
class doesn't have any initializers (but Encoding.find()
can load some of the encodings IConv
supports dynamically) Unfortunately afaik Mazovia
is unsupported even in iconv
, so you're stuck with implementing your own class...
这篇关于创建自己的编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!