msgpack / msgpack-javascript

@msgpack/msgpack - MessagePack for JavaScript / msgpack.org[JavaScript/TypeScript/ECMA-262]
https://msgpack.org/
ISC License
1.3k stars 162 forks source link

Allow decoding raw strings #235

Open jasonpaulos opened 1 year ago

jasonpaulos commented 1 year ago

This PR adds the ability to skip UTF-8 decoding of strings when you enable the rawStrings decoding option.

This is useful because I have encountered some encoded msgpack strings which do not contain valid UTF-8 data, and without a feature like this, it would be impossible to decode them properly.

According to the msgpack spec, this ability is encouraged:

  • String objects may contain invalid byte sequence and the behavior of a deserializer depends on the actual implementation when it received invalid byte sequence
    • Deserializers should provide functionality to get the original byte array so that applications can decide how to handle the object