Hi Jonh and Paul,

From8BitData() is static and To8BitData()  mentioned in

(http://sourceforge.net/p/wxlua/mailman/message/32175781/)

but allowing to specify codepage (wxConvISO8859_1 or whatever) would be 
enought

best
victor

----- Original Message ----- 
From: "Victor Bombi" <son...@telefonica.net>
To: <wxlua-users@lists.sourceforge.net>
Sent: Monday, March 02, 2015 10:58 AM
Subject: [wxlua-users] wxLua ANSI to WCHAR (was wxString::ToAscii)


> This is lua2wx, it seems that it takes utf8 strings instead or ANSI with
> local codepage
> WXLUA_USE_WXSTR_CONVCURRENT 1 should be tried?
>
> ------------------------------------------------------------
> #define WXLUA_USE_WXSTR_CONVUTF8    1
> #define WXLUA_USE_WXSTR_CONVCURRENT 0
>
> // Convert a 8-bit ANSI C Lua String into a wxString
> inline WXDLLIMPEXP_WXLUA wxString lua2wx(const char* luastr)
> {
>    if (luastr == NULL) return wxEmptyString; // check for NULL
>
> #if WXLUA_USE_WXSTR_CONVUTF8
>
>    return wxString(luastr, wxConvUTF8);
>
> #elif WXLUA_USE_WXSTR_CONVCURRENT
>
>    return wxString(luastr, *wxConvCurrent);
>
> #else //!WXLUA_USE_WXSTR_CONVCURRENT
>    #if wxUSE_UNICODE
>        wxString str(luastr, wxConvUTF8);
>    #else
>        wxString str(wxConvUTF8.cMB2WC(luastr), *wxConvCurrent);
>    #endif // wxUSE_UNICODE
>
>        if (str.IsEmpty())
>            str = wxConvertMB2WX(luastr); // old way that mostly works
>
>        return str;
> #endif //WXLUA_USE_WXSTR_CONVCURRENT
> }
> --------------------------------------------------------------
>
> As an example compare wxLua with iconv:
> It seems wxLua dont take ANSI but UTF-8
> --------------------------------------------------
> local iconv = require("iconv")
> oldprint = print
> require"wx"
> print=oldprint
> local str = ""
> for i=0,255 do
> str = str .. string.char(i)
> end
> local cd = iconv.new("utf-8" .. "//TRANSLIT", "iso-8859-1")--IGNORE
> --local cd = iconv.new("iso-8859-1" .. "//TRANSLIT", "utf-8")
> assert(cd, "Failed to create a converter object.")
>
>
> function showerr(err)
>  if err == iconv.ERROR_INCOMPLETE then
>    print("ERROR: Incomplete input.")
>  elseif err == iconv.ERROR_INVALID then
>    print("ERROR: Invalid input.")
>  elseif err == iconv.ERROR_NO_MEMORY then
>    print("ERROR: Failed to allocate memory.")
>  elseif err == iconv.ERROR_UNKNOWN then
>    print("ERROR: There was an unknown error.")
>  end
> end
>
>
> for i=1,#str do
> local char = tostring(str:byte(i))
> --ANSI to UTF8
> local conv ,err= cd:iconv(str:sub(i,i))
> showerr(err)
> print(str:byte(i) , conv:byte(1,#conv))
> --ANSI to UTF8 in wx
> local convwx = wx.wxString(str:sub(i,i)):GetData()
> print(str:byte(i) , convwx:byte(1,#convwx))
> --UTF8 to UTF8 in wx
> local convwx2 = wx.wxString(conv):GetData()
> print(str:byte(i) , convwx2:byte(1,#convwx2))
> end
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, 
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for 
> all
> things parallel software development, from weekly thought leadership blogs 
> to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> wxlua-users mailing list
> wxlua-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wxlua-users 


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to