On Wed, May 9, 2012 at 2:45 PM, Andre Arpin <ar...@kingston.net> wrote: > Hi, > > wxString str = wxString(luastr, wxConvUTF8); > return str.Length()==0 ? wxString(luastr) : str; > > This solution may look crazy but works surprisingly well. > > We have no idea what kind of file has just been read. > Guessing is are only choice. If it is not UTF8 we are in trouble.
I don't know what you mean? This is how the conversion is currently done. Lua is assumed to be UTF8 which works normally for regular English ASCII C-strings (I'm sure there's an official name for it, UTF7 I guess). Search for the "lua2wx" and "wx2lua" functions here : http://wxlua.svn.sourceforge.net/viewvc/wxlua/trunk/wxLua/modules/wxlua/include/wxlstate.h?revision=72&view=markup > What happen to string.match(string,"%a") in either cases for example? They stop matching once the first multibyte Unicode char is found since it will be > 128 See the description here: http://en.wikipedia.org/wiki/UTF-8 It is up to the Lua programmer to know (or check) if a string may contain multibyte Unicode chars or not before using Lua's string functions since they assume single byte chars. Regards, John ps. On the wxWidgets mailing list they are currently discussing whether they should switch to UTF32 always so you don't have to use iterators since each char is always 4 bytes. The downside is wasted memory, the upside is that each code point (glyph) is a known length making text manipulation much easier. In any case, I believe that wxLua will have to stick to UTF8 so that "regular" C-strings (<128) are able to be handled using the Lua string functions. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users