[erlang-questions] UTF8

Hasan Veldstra <>
Tue Feb 12 08:59:04 CET 2008


> How can I write [332,116,97,44,32,71,117,110,109,97] to a file so  
> that when I open it up it looks like "Ōta, Gunma"?


-module(ftest).
-export([run/0]).

run() ->
     Data = [197,140,116,97,44,32,71,117,110,109,97],
     file:write_file("ftest.txt", list_to_binary(Data)).


Text is just numbers when stored to disk.

By the way, the list of numbers you originally posted is "Ōta, Gunma"  
encoded in UTF-32, not UTF-8. It's in UTF-8 in my example.

Hope this helps.


More information about the erlang-questions mailing list