Hex encoding functions on the binary module

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Hex encoding functions on the binary module

Bryan Frimin
Hello everyone,

I propose to add the encode_hex/1, encode_hex/2 and decode_hex/1
functions on the binary module[1].

Dealing with the hex format is frequent in many codebases. At this time,
we all copy-paste similar helpers in our codebases to encode and decode
a hex-encoded binary.

It's why I suggest enriching the binary module with these functions.

I've added these functions on the binary module because it makes sense
to me, and it avoids polluting the global namespace with a new
module. Maybe create a new module called hex, for example, is a better
solution.

I tried as much as possible to follow the contribution guide. Don't
hesitate to tell me if I made a mistake somewhere.

Regards,

--
Bryan Frimin
https://www.frimin.fr
[hidden email]

[1] https://github.com/erlang/otp/pull/3014
Reply | Threaded
Open this post in threaded view
|

Re: Hex encoding functions on the binary module

Max Lapshin-2
Excellent!

We all have this code in each project =)

On Sat, Jan 30, 2021 at 11:22 AM Bryan Frimin <[hidden email]> wrote:

>
> Hello everyone,
>
> I propose to add the encode_hex/1, encode_hex/2 and decode_hex/1
> functions on the binary module[1].
>
> Dealing with the hex format is frequent in many codebases. At this time,
> we all copy-paste similar helpers in our codebases to encode and decode
> a hex-encoded binary.
>
> It's why I suggest enriching the binary module with these functions.
>
> I've added these functions on the binary module because it makes sense
> to me, and it avoids polluting the global namespace with a new
> module. Maybe create a new module called hex, for example, is a better
> solution.
>
> I tried as much as possible to follow the contribution guide. Don't
> hesitate to tell me if I made a mistake somewhere.
>
> Regards,
>
> --
> Bryan Frimin
> https://www.frimin.fr
> [hidden email]
>
> [1] https://github.com/erlang/otp/pull/3014