Current section

Files

Jump to
glentities src glentities@hex_encoder.erl
Raw

src/glentities@hex_encoder.erl

-module(glentities@hex_encoder).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([encode/1]).
-spec do_encode(binary()) -> binary().
do_encode(Text) ->
_pipe = Text,
_pipe@1 = gleam@string:to_utf_codepoints(_pipe),
_pipe@2 = gleam@list:map(
_pipe@1,
fun(Codepoint) -> case gleam@string:utf_codepoint_to_int(Codepoint) of
C when ((((((C =:= 9) orelse (C =:= 10)) orelse (C =:= 13)) orelse (C =:= 32)) orelse ((C >= 48) andalso (C =< 57))) orelse ((C >= 65) andalso (C =< 90))) orelse ((C >= 97) andalso (C =< 122)) ->
gleam_stdlib:utf_codepoint_list_to_string([Codepoint]);
Encodable ->
<<<<"&#x"/utf8, (gleam@int:to_base16(Encodable))/binary>>/binary,
";"/utf8>>
end end
),
gleam@string:join(_pipe@2, <<""/utf8>>).
-spec encode(binary()) -> binary().
encode(Text) ->
_pipe = Text,
_pipe@1 = unicode:characters_to_nfc_binary(_pipe),
do_encode(_pipe@1).