lua-users home
lua-l archive

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


Asko Kauppi wrote:

..keeping my fingers out of the hot oven, but..

local str= "This might be in Kanji: "..U(1234)..U(5678).." is that enough? :)"

Yes, that would of course work, too. But that's lots of noise compared to: "This might be in Kanji:\u+1234\u+5678", IMHO.

Note that, according to the unicode spec 'u' and 'U' are not equivalent. 'u' expects 4 hex digits, allowing for a UCS16 character, while 'U' expects 8 hex digits, for a UCS32 character. But that's just for parsing the string. In UTF8 \U+00001234 and \u+1234 produce the same sequence.



I don't oppose the \U, no I don't. If they do it, also \x (hex input) should be in..

Agreed, although Lua already supports '\123' for decimal literals. Unlike C, the number here is interpreted as decimal rather than octal. Not a bad diff, considering how obsolete octal is! Hex notation would merely be a convenience for representing single characters. The nice thing about \u is that it actually does some grungy work for you. Today you could enter this:

    "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 :-)

--
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"'