|
I don't know iconv, but "\" is an escape character, try this;> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> Behalf Of Chris Datfung
> Sent: maandag 14 oktober 2013 10:57
> To: Lua mailing list
> Subject: iconv [was: HTML Encoding]
>
> After a bit more re-engineering, I removed the need to html encode the
> data. My question is now as follows:
>
> I have a variable thats latin-1 encoded, e.g. montr\xe9al . I want to
> convert that to montréal. I think I can use iconv, but using the iconv
> documentation, I'm not getting the expected output.
>
> iconv = require("iconv")
> cd = iconv.new('latin1', 'utf8')
> city = "montr\xe9al"
> nstr, err = cd:iconv(city)
> print(nstr)
>
> returns: montrxe9al
> How can I convert montr\xe9al to montréal?
> Thanks,
> Chris
city = "montr\\xe9al" -- an alternative would be; city = [[montr\xe9al]]
iconv = require("iconv")
cd = iconv.new('latin1', 'utf8')
nstr, err = cd:iconv(city)
print(nstr)