msgpack / msgpack

MessagePack is an extremely efficient object serialization library. It's like JSON, but very fast and small.

Home Page:http://msgpack.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support of ASCII strings

devOneTwoThree opened this issue · comments

We use MsgPack for unpacking data that has been packed by some external partner (I think they use a PHP implementation of MsgPack).

The strings in the packets are encoded in ASCII (codepage 1252). Unpacking works in most cases but not when strings contain german Umlaute.

I implemented my own 'Unpacker' which is basically just a wrapper of the default unpacker that only overrides the ReadString(out string result) Method. Works for me, but is not very convenient. I would appreciate an easier possibility to support different encodings. E.g. if Unpacker.Create(..) would have an option to specify the encoding or if there were an implementation of AsciiUnpacker delivered with MsgPack.

Here is my implementation of AsciiUnpacker and a usage example:

var serializer = MessagePackSerializer.Get<MyType[]>(_context); Unpacker unpacker = new AsciiUnpacker(stream); MyType[] data = serializer.UnpackFrom(unpacker);
AsciiUnpacker.txt