<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>