<div dir="ltr"><div dir="ltr"><br></div><div>In my opinion, this should not be done, strings and in particular unicode strings seem</div><div>to be very confusing as it is with two representations in OTP APIs.<br></div><div><br></div><div>UTF-8 (and friends) is an encoding of UNICODE codepoints, you should never</div><div>operate on the encoding </div><div><br></div><div><br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 24, 2021 at 10:35 AM Michael Truog <<a href="mailto:mjtruog@gmail.com">mjtruog@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I was wondering if there was interest in modifying the io interpretation <br>
of "~ts" to allow an integer between the t and s for forcing a <br>
particular unicode interpretation.  That would allow a list of bytes to <br>
be interpreted as UTF8, to provide the same output as a binary:<br>
1> io:format("~ts~n",[<<16#C2,16#A2>>]).<br>
¢<br>
ok<br>
2> io:format("~t8s~n",[[16#C2,16#A2]]).<br>
¢<br>
ok<br>
<br>
I was also wondering if bytestring types would be added to Erlang/OTP, like:<br>
-type nonempty_bytestring() :: nonempty_list(byte()).<br>
-type bytestring() :: list(byte()).<br>
<br>
They are useful in iolists to ensure only bytes (not other integers) are <br>
in nested lists.<br>
<br>
Best Regards,<br>
Michael<br>
</blockquote></div></div>