abh*_*jan 3 unicode erlang odbc
我有一个字符串值作为aman,<<97,0,109,0,97,0,110,0>>当我这样做时打印:
A=<<97,0,109,0,97,0,110,0>>
erlang:binary_to_list(A)
Run Code Online (Sandbox Code Playgroud)
我得到[97,0,109,0,97,0,110,0]
但我需要一个字符串作为"阿曼"或简单的阿曼
如何才能做到这一点?
使用unicode:characters_to_list/2,在第二个参数中指定二进制的编码:
> A = <<97,0,109,0,97,0,110,0>>.
<<97,0,109,0,97,0,110,0>>
> unicode:characters_to_list(A, {utf16, little}).
"aman"
Run Code Online (Sandbox Code Playgroud)