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