L1330 - Truncated Character in Binary String
Warningβ
karate() ->
<<"η©Ίζπ">>.
%% ^^^^^^^^^ warning: character code larger than 255 will be truncated
Explanationβ
A binary text segment with no /utf8, /utf16, or /utf32 specifier is encoded
using one byte per character (Latin-1), for historical reasons. Characters with
code points above 255 do not fit in a single byte and are truncated, so the
resulting binary represents different characters than the ones in the source code.
In the example, <<"η©Ίζπ">> is silently encoded as <<"zKB">>.
%% Instead of:
karate() -> <<"η©Ίζπ">>.
%% Write (UTF-8):
karate() -> <<"η©Ίζπ"/utf8>>.
%% Or, since OTP 27, simply:
karate() -> ~"η©Ίζπ".
This warning can be suppressed with -compile(nowarn_truncated_character), but
note that the truncated result is almost never what you want. See also
L1329.