lua-users home
lua-l archive

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


Klaus Ripke wrote:
On Thu, Dec 29, 2005 at 04:10:26PM -0800, Chris Marrin wrote:

   "This is a summation character: \226\136\145"

and a console that understood UTF8 would show a summation characer. But to do this I had to:

- Use to the Character Map utility to find the character
- Copy that character into OpenOffice, which understands Unicode
- Save the file as UTF8
- Open the file as binary in MsDev
- Hand convert the character sequence to UTF8
- Use Calculator to convert the result into decimal

It would be nice if Lua could do this for me :-)

what should Lua do for you?
Use to the Character Map utility?
Copy that character into OpenOffice?
Or write the one line Lua script to print the decimal
numbers corresponding to the UTF-8 representation
of a given Unicode point?
No problem, Lua does it for you.
The attached utftab prints 64 chars a line with their
base Lua string encoding; just add 0-63 to the last \128.
Run it in a UTF-8 xterm.
Use ncurses (or some extremely antisocial hacks from slnspider)
to add mouse support to print the code for any character.

However, your list pretty much makes the point that the problem
is not whether to write some u+xxx or two or three decimal codes.
You want to use either an Unicode capable editor
or some utility to look up codes
-- as long as everybody agrees to use UTF-8 anyway, that is.
It does make a big difference though where friends of the wide char
want their wchar_t based version of Lua. Anybody?

I think UTF8 is a good representation (I used to be in the wchar_t camp). The utility of \U is simply convenience, doing the work of converting a hex unicode value into UTF8. There are other ways to do it, including some Lua code to do the translation.

I think the more important addition would be an easy Lua way to set the locale to use the UTF8 encoding.

--
chris marrin                ,""$,
chris@marrin.com          b`    $                             ,,.
                        mP     b'                            , 1$'
        ,.`           ,b`    ,`                              :$$'
     ,|`             mP    ,`                                       ,mm
   ,b"              b"   ,`            ,mm      m$$    ,m         ,`P$$
  m$`             ,b`  .` ,mm        ,'|$P   ,|"1$`  ,b$P       ,`  :$1
 b$`             ,$: :,`` |$$      ,`   $$` ,|` ,$$,,`"$$     .`    :$|
b$|            _m$`,:`    :$1   ,`     ,$Pm|`    `    :$$,..;"'     |$:
P$b,      _;b$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'