sovr610 / luainterface

Automatically exported from code.google.com/p/luainterface
1 stars 0 forks source link

Usage of Marshal::PtrToStringAnsi invalidates 8-bit clean guarantee of Lua #48

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The Marshal::PtrToStringAnsi function converts all byte values greater than 127 
to 63, therefore making it useless as an 8-bit clean option.

Since Lua does not specify a character encoding for its strings, there's no 
good solution here if you want to support Unicode and interop with Lua. 
However, I don't think you should be making things worse via the LuaInterface 
layer by destroying data with Marshal::PtrToStringAnsi.

If you offer a lossless data conversion operation that just widens the 8-bit 
values to 16-bit values for storage in a managed string then the application 
itself can deal with the character encoding fiasco. Yes, that'll involve 
converting the string to a `char[]` and then pulling out the `byte` values from 
there. Perhaps just offering the string as a `char[]` would be best?

What version of the product are you using? On what operating system?
LuaInterface 2.0.3

Original issue reported on code.google.com by james.jdunne@gmail.com on 23 Apr 2012 at 1:29