lua-users home
lua-l archive

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


Hi,

David Haley wrote:
> print(os.setlocale("fr_FR.utf8"))

You don't need this anymore. The libc locale is ignored because
slnunicode has its own UTF-8 functions.

> require "unicode"
> 
> local s = "hello abcdéf there"
> 
> for word in unicode.utf8.gmatch(s, "%w+") do
>     print(word)
> end

Entering this into an UTF-8 encoded source file, I get:

hello
abcdéf
there

Maybe your source file is still in ISO-8859-1 encoding?

Try: iconv -f iso-8859-1 -t utf-8 <oldfile >newfile

> Incidentally, the 'unitest' file doesn't appear to work: unicode.utf8 is
> nil, but the test code seems to assume that it isn't. Do I need to do
> something special when I compile the library, or is the test file out of
> sync with the library? Am I doing something wrong?

I think the library initializer function is buggy. It relies on
some internal Lua functions and also returns the unicode.utf8
table whereas it should really return the unicode table itself.

[Klaus Ripke are you reading this?]

To fix this remove the 'lua_pop(L, 1);' in line 1324 and add a
'lua_settop(L, 2);' just before the final 'return 1;'. Now
recompile: cc -shared -Wall -Os -fpic -o unicode.so slnunico.c
And try the test cases: lua unitest

Bye,
     Mike