1

I have C# code calling a lua function. I'm passing string to this function. This function processes the string and returns another string in a table.

When I try to pass 'chinese' string "怎么说" - I get "???" in lua. (I tried to print and save this string to file). My C# encoding is correct as I can see the correct chinese characters in visual studio debugging session. How do I pass the 'chinese' string to lua?

Appreciate any help.

  • 1
    How are you passing the string to lua? Are you manipulating the string in lua? What encoding is the string in? How are you printing the string to see it? – Etan Reisner Aug 21 '14 at 01:44
  • How are you passing the string to lua? I'm passing the string as part of a object. This object is passed using LuaTable. Are you manipulating the string in lua? At present I'm not manipulating it, but I intent to. What encoding is the string in? Utf-8 How are you printing the string to see it? 1. I'm using lua print() statement 2. Lua io.file() to write to file 3. When the C# function returns I check string using visual studio – Sandeep Aparajit Aug 21 '14 at 01:53
  • Are you passing raw bytes? As a string? What encoding? A userdata? As a pointer? – Etan Reisner Aug 21 '14 at 01:54
  • Sorry I hit enter too soon. How are you passing the string to lua? I'm passing the string as part of an object. This object is passed using LuaTable. Are you manipulating the string in lua? At present I'm not manipulating it, but I intent to. What encoding is the string in? Utf-8. How are you printing the string to see it? 1. I'm using lua print() statement, 2. Lua io.file() to write to file, 3. When the C# function returns I check string using visual studio – Sandeep Aparajit Aug 21 '14 at 01:56
  • You are using `lua_pushstring` (or similar) to push it to lua? Where does `print()` display to? Is that console ready for UTF-8 text? What do you mean by `io.file()`? If you are pushing the literal string to lua and writing those bytes to a file that should work just fine. – Etan Reisner Aug 21 '14 at 02:09
  • Are you using pre-build NLua or building your own? – Vinicius Jarina Aug 24 '14 at 22:27

1 Answers1

2

This was a issue in NLua.

Was already fixed: https://github.com/NLua/NLua/issues/48

Vinicius Jarina
  • 797
  • 5
  • 16
  • I have the same issue with NLua when I use `Lua.DoString('some code with cyrillic characters')` with cyrillic characters. Here is [PR](https://github.com/NLua/NLua/pull/223) – hal Jan 17 '17 at 13:51