Skip to content

Conversation

@seriyps
Copy link

@seriyps seriyps commented Oct 17, 2024

This addresses the #40

However it doesn't add support to encode_prefix / decode_prefix, mainly because Legacy option was not supported there as well. However I think I should actually add it. Maybe separate commit?
Readme should be probably updated as well.

I didn't run tests because I don't have quickcheck, but it compiles and seems to work:

1> sext:encode('привет').
** exception error: bad argument
     in function  atom_to_binary/2
        called as atom_to_binary('привет',latin1)
        *** argument 1: contains a character not expressible in latin1
     in call from sext:encode_atom/2 (/Users/sergey.prokhorov/workspace/sext/src/sext.erl, line 411)
2> sext:encode('привет', #{atom_encoding => utf8}).
<<12,232,111,250,56,14,134,227,161,178,232,109,122,56,32,8>>
3> sext:decode(sext:encode('привет', #{atom_encoding => utf8})).
'пÑ\200ивеÑ\202'
4> sext:decode(sext:encode('привет', #{atom_encoding => utf8}), #{atom_encoding => utf8}).
'привет'

So, what do you think?

@uwiger
Copy link
Owner

uwiger commented Oct 17, 2024

I think you need to handle the code being called with a (legacy) boolean() argument as well.
Annoying, but won't be that hard.

@seriyps
Copy link
Author

seriyps commented Oct 17, 2024

Done, good point!

@uwiger
Copy link
Owner

uwiger commented Oct 25, 2024

Thanks. Will try to test this during the weekend.

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.

2 participants