bennyxqg / lua-alchemy

Automatically exported from code.google.com/p/lua-alchemy
0 stars 0 forks source link

as3.tolua corrupts text encoding #123

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
These tests fail (add them to TestAS3LuaInterface.as)

    public function testAS3ToLuaForeignStringAS3():void
    {
      lua_wrapper.setGlobal(luaState, "HELLO", "Привет!");
      var script:String = ( <![CDATA[
        assert(as3.tolua(HELLO) == "Привет!", "HELLO is corrupted")
        ]]> ).toString();
      var stack:Array = lua_wrapper.luaDoString(luaState, script);
      assertTrue(stack[0]);
      assertEquals(1, stack.length);
    }

    public function testAS3ToLuaForeignStringPassThroughSimple():void
    {
      lua_wrapper.setGlobal(luaState, "HELLO", "Привет!");
      var script:String = ( <![CDATA[
        return as3.tolua(HELLO)
        ]]> ).toString();
      var stack:Array = lua_wrapper.luaDoString(luaState, script);
      assertTrue(stack[0]);
      assertEquals("tolua", "Привет!", stack[1]);

      assertEquals(2, stack.length);
    }

Original issue reported on code.google.com by aglad...@gmail.com on 10 Sep 2009 at 12:08

GoogleCodeExporter commented 9 years ago
Error message from testAS3ToLuaForeignStringPassThroughSimple:

    Error: tolua - expected:<Привет!> but was:<ПриÐ>

Original comment by aglad...@gmail.com on 10 Sep 2009 at 12:11

GoogleCodeExporter commented 9 years ago
Fixed with this commit:
http://github.com/lua-alchemy/lua-
alchemy/commit/453f33e2af7e11b96301b8291085e36677e71b7e

Original comment by aglad...@gmail.com on 10 Sep 2009 at 3:50

GoogleCodeExporter commented 9 years ago
Note: Actually that was a silly bug with multibyte string handling, not with 
encoding. 
We've tried to measure buffer length as a number of multibyte characters, not 
as a 
number of bytes.

Original comment by aglad...@gmail.com on 19 Sep 2009 at 7:49