<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>I think my questions is wrong. It is not a latin1 encoded string. It is actually utf8 encoded string but be read by Erlang into [232,191,153] represented by a latin - charlist.<br><br>A simple list_to_binary will give me back the UTF8 already. It's just I need a list to accommodate other part of the program.  <br><br>I am using a web framework(Chicagoboss). I posted the data into Erlang in Chinese in utf8 encoded string from a web form. It is read by Erlang as [232,191,153]. This is just one single Chinese character. But erlang read it as [232,191,153]. So I want to consume via ajax later on on the client side. <br><br>But because this piece of information is in a blob of long json data and it is needed to be converted to binary before sending down the wire. So in order to make this piece of information to be correctly converted as one part of the whole assembled json, it needs to turn to a utf8 list first like this: <br><br>asn1rt:utf8_binary_to_list(list_to_binary([232,191,153])), <br><br>this will give me [36825] which represent the same Chinese character as  <<232,191,153>>. You can test this by  <br>io:format("~ts~n",[[36825]]). and io:format("~ts~n",[<<232,191,153>>]). They all output the same character: Õâ<br><br>then later, asn1rt:utf8_list_to_binary will convert all the json data together to binary. <br></div><div><br><br></div><div style="position:relative;zoom:1">--<br>Hao<br><br>  <div style="clear:both"></div></div><div id="divNeteaseMailCard"></div><br>ÔÚ 2015-07-27 00:14:16£¬"Jesper Louis Andersen" <jesper.louis.andersen@gmail.com> Ð´µÀ£º<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jul 26, 2015 at 3:11 PM, Íõê» <span dir="ltr"><<a href="mailto:jusfeel@163.com" target="_blank">jusfeel@163.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Hi,<br>Does anyone know if this is a proper way to convert latin string to utf-8 string?<br><br></div><div>{ok, S} = asn1rt:utf8_binary_to_list(list_to_binary([232,191,153])).<br>io:format("~ts~n",[S]).</div></blockquote></div><br>Use the `unicode` module for character conversion:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">1> unicode:characters_to_binary([232,191,153], latin1, utf8).</div><div class="gmail_extra"><<195,168,194,191,194,153>></div><div class="gmail_extra">2> io:format("~ts~n", [v(1)]).</div><div class="gmail_extra"><br></div><div class="gmail_extra">It prints as three characters:</div><div class="gmail_extra"><br></div><div class="gmail_extra">LATIN SMALL LETTER E WITH GRAVE</div><div class="gmail_extra">INVERTED QUESTION MARK</div><div class="gmail_extra">(unbound 0x0099 part of the Latin-1 supplement range)</div><div class="gmail_extra"><br></div><div class="gmail_extra">I don't know if this is correct for you.</div><div class="gmail_extra"><br></div><div class="gmail_extra">What are you trying to do generally? That is, what is the problem you are having. Perhaps we can give better help if we know your situation.</div><div><br></div>-- <br><div class="gmail_signature">J.</div>
</div></div>
</blockquote></div>