Skip to content

Conversation

@jasonpaulos
Copy link

@jasonpaulos jasonpaulos commented Jul 16, 2024

#3 and #5 added support for decoding raw binary strings, i.e. leaving the value a a byte array instead of decoding into a string object.

This PR does the same for encoding -- you can now encode a byte array as a string. To do so, create an instance of the new RawBinaryString class that wraps your byte array. This type will encode the byte array contents as a string type.

These operations are useful when you must comply with a legacy protocol that uses the string family for values that can contain invalid UTF-8 sequences.

Additionally, during decoding, you can specify the useRawBinaryStringClass option for raw binary strings to be decoded as the new RawBinaryString class. With this, it's now possible to do a complete round-trip decoding and encoding of an object using raw binary strings.

@jasonpaulos jasonpaulos marked this pull request as ready for review July 16, 2024 19:47
@jasonpaulos jasonpaulos merged commit 6600a96 into main Jul 31, 2024
@jasonpaulos jasonpaulos deleted the raw-string-encoding branch July 31, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants