[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: iconv [was: HTML Encoding]
- From: Thijs Schreijer <thijs@...>
- Date: Mon, 14 Oct 2013 09:26:43 +0000
> -----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
I don't know iconv, but "\" is an escape character, try this;
iconv = require("iconv")
cd = iconv.new('latin1', 'utf8')
city = "montr\\xe9al" -- an alternative would be; city = [[montr\xe9al]]
nstr, err = cd:iconv(city)
print(nstr)