lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sun, 2008-05-25 at 12:40 +0800, Pete Kay wrote:
> If I want to have a String map in a file, one for each locale, can Lua
> read and display the unicode character?  

As PA already explained:

> Sure, a Lua string can store any byte sequence.

Additionally you should use a Content-Type header to let web browsers
know what character set is used in your web pages, for example:

  Content-Type: text/html; charset=utf-8

If you do this properly your web application will only ever receive
strings encoded in UTF-8 which means you won't need any conversion. An
alternative to the header above is to use the following meta tag in your
HTML:

  <meta name="Content-Type" content="text/html; charset=utf-8">

This has worked very well for me in PHP, which is as handicapped in
character set handling as Lua is (both of them mostly ignore character
set encodings and treat strings as arrays of bytes.)

Good luck,

 - Peter Odding