Is it possible to convert Erlang binary UTF-8 string (like <<"HELLO">>
) to lowercase without converting it to list and back?
To be clear: utf8 does not equal binary. The files are not identical. The UTF8 version is bigger. Press the "Raw" button, then you will see a difference.
In order to convert a String into UTF-8, we use the getBytes() method in Java. The getBytes() method encodes a String into a sequence of bytes and returns a byte array. where charsetName is the specific charset by which the String is encoded into an array of bytes.
If you know how to lowercase unicode character and key words here are "without converting it to list and back", then the answer could be:
<< <<(unicode_to_lower(C))/utf8>> || <<C/utf8>> <= <<"HELLO">> >>.
string:lowercase in Erlang 20 works with binaries:
1> string:lowercase(<<"HELLO">>).
<<"hello">>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With