unicode:characters_to_binary/3
把一个字符集数据转换为一个 UTF-8 的二进制数据
用法:
characters_to_binary(Data, InEncoding, OutEncoding) -> Result
把一个字符集数据 Data 转换为一个 UTF-8 的二进制数据,并把传入的数据 Data 的编码定义解释为 InEncoding,把生产数据的编码定义为 OutEncoding。
unicode:characters_to_binary("中文字符", utf8, utf8).
Result = unicode:characters_to_binary("中文字符", utf8, utf8), io:format("~ts ~n", [Result]).