lua-users home
lua-l archive

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


Hi Lua list,

I am trying to use character classes %a and %w to match against strings
with utf8 accented characters. I found the following threads in the
archives where people have similar problems:

#1
http://lua-users.org/lists/lua-l/2006-11/msg00502.html
#2
http://lua-users.lua.org/lists/lua-l/2005-11/msg00065.html

The gist of it seems to be that you need to set the locale before using
the matching functions.

I tried doing just that, following Mike Pall's suggestion of breaking
the script into two parts:

$ cat script.lua
--------------------------------------
os.setlocale("fr_FR.utf8", "ctype")

dofile "script1.lua"
--------------------------------------

$ cat script1.lua
--------------------------------------
é = 1
print(é)
--------------------------------------


But then I get:

$ lua script.lua
lua: script1.lua:1: unexpected symbol near '�'
stack traceback:
        [C]: in function 'dofile'
        script.lua:5: in main chunk
        [C]: ?


Any idea why this is not working?
(The pattern matching doesn't work, either.)


Here is the information that I think is relevant, please let me know if
I should provide anything else:

- My main locale is en_US.UTF-8   (i.e., echo $LANG --> en_US.UTF-8)

- When I print the result of os.setenv("fr_FR.utf8"), I get fr_FR.utf8
(which I believe means 'success')

- I am running under a fully updated Ubuntu 7.04 system

- My Lua version is 5.1.1, unmodified from the Ubuntu repositories

- Same behavior on vanilla 5.1.2


Thanks in advance,
- David


-- 
~David-Haley
http://david.the-haleys.org