0

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 )

SomeKittens
  • 38,868
  • 19
  • 114
  • 143

2 Answers2

1

To your updated question: At the moment all you can do is write some custom code which handles file reading/writing at byte level and does the needed conversions.


If you refer to how you can use different character encodings in ruby with version 1.9 I point you to

Working with Encodings in Ruby 1.9 and

Understanding M17n

jitter
  • 53,475
  • 11
  • 111
  • 124
  • he ment implementing an Encoding instance for an Encoding that is unsupported by default on ruby – SztupY Jun 21 '09 at 01:06
1

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...

SomeKittens
  • 38,868
  • 19
  • 114
  • 143
SztupY
  • 10,291
  • 8
  • 64
  • 87