| Andreas Rozek | |
|
|
|
LuaJava_09 - what happens to Unicode strings?Lua uses 8-bit strings while Java is Unicode-based - thus: what happens to Java strings which cannot be represented using 8-bit characters? LuaJava_09 goes further into this question.
Please, also consider my "Hints for Reading"
and the "List of Recent Changes"! |
LuaJava_09
The script itself is extremely simple and should not require any further
explanation. The accompanying Java source may be compiled using javac LuaJava_09.java and does not need the luajava package. The resulting class file should be copied to a place where it can be found by the Java class loader (e.g., into a directory which is automatically scanned by the Java extension mechanism).
After an invocation of the form java luna.LuaJava LuaJava_09.lua the script produces the following output LuaJava_09 - what happens to Unicode strings?
Lua2Java('abc') -> \u0061\u0062\u0063
Java2Lua('\u0161\u0262\u0363') -> ??
(length = 6, content = "\197\161\201\162\205\163")
(for a comparison "\97\98\99" = "abc")
Which is probably not what one might expect:
|
Source CodeThe source code of this script and its accompanying Java class is publically available: |
DisclaimerPlease, also consider the author's Disclaimer! |
|
|
|
| http://www.Andreas-Rozek.de/LuaJava/Acquainting/LuaJava_09_en.html | (last Modification: 26.11.2004) |