mbraceproject / FsPickler

A fast multi-format message serializer for .NET
http://mbraceproject.github.io/FsPickler/
MIT License
326 stars 52 forks source link

Default encoding add BOM to output which create invalid Json string #17

Closed thinkbeforecoding closed 10 years ago

thinkbeforecoding commented 10 years ago

when using json.Pickle v with default encoding, the result is a byte[] starting with UTF8 byte order mark.

This first caracter is not valid in json and is not ignored by others deserializers (try with jsonlint).

A workaround is to use System.Text.UTF8Encoding(false) for encoding, but it could be better to use it as default.

eiriktsarpalis commented 10 years ago

Currently, UTF8 is the system-wide default. This was chosen since it is the optimal encoding for BinaryWriter in the binary format. A solution to this perhaps would be to let each format implementation choose its own default encoding, by making IPickleFormatProvider take optionals.

eiriktsarpalis commented 10 years ago

I have attempted to address the issue here: bc91d26a0096cdee05aac1ad80313f5c534ba31c

Let me know if this works.

thinkbeforecoding commented 10 years ago

Yes it works ! Great