> Erlang中文手册 > characters_to_binary/1 把一个字符集数据转换为一个 UTF-8 的二进制数据

unicode:characters_to_binary/1

把一个字符集数据转换为一个 UTF-8 的二进制数据

用法:

characters_to_binary(Data) -> Result

把一个字符集数据 Data 转换为一个 UTF-8 的二进制数据,其效用跟 unicode:characters_to_binary(Data, unicode, unicode) 一样。

unicode:characters_to_binary("中文字符").
Result = unicode:characters_to_binary("中文字符"),
io:format("~ts ~n", [Result]).