On Feb 12, 2008 3:05 AM, Hakkı Doğusan <[EMAIL PROTECTED]> wrote:
> >
> > The problem with string comparison in the new version persists.
> >
> > --------------------------
> > wx.wxLocale( wx.wxLANGUAGE_DEFAULT )
> > local loc= wx.wxGetLocale()
> > local s = 'Maçã'
> > print(loc:GetString(s), s)
> > print('loc:GetString(s)==s  ->', loc:GetString(s)==s)  -- first
> > print( "s=='Maçã'  ", s=='Maçã' )                                 -- second
> >
> > ---------------
> > On previous version of wxLua the first comparison return true.
> > But in the new version return false.

What am I doing wrong that the code you show works fine!
I tested with wxLuaEditor in Linux w/ Unicode and MSW non-Unicode with
the current wxLua code and the code below for lua2wx() and wx2lua().

> > I suspect wxLua convert the lua_string to another charset(UTF-8) and
> > then it fail.
>
> Yes, wxLua assumes utf8 in unicode build. Do you have a chance to
> re-compile wxLua for testing? I'm modifying lua2wx and wx2lua as follows
> (for unicode build and Turkish locale):
>
> ----- file: modules/wxlua/include/wxlstate.h ------------
> // 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
>
> #ifdef __WXGTK__
> #if wxUSE_UNICODE
>      wxString str(luastr, wxConvUTF8);
> #else
>      wxString str(wxConvUTF8.cMB2WC(luastr), *wxConvCurrent);
> #endif // wxUSE_UNICODE
> #else
>      wxString str(luastr, *wxConvCurrent);
> #endif
>
>      if (str.IsEmpty())
>          str = wxConvertMB2WX(luastr); // old way that mostly works
>
>      return str;
> }
>
> // Convert a wxString to 8-bit ANSI C Lua String
> inline const /*WXDLLIMPEXP_WXLUA*/ wxCharBuffer wx2lua(const wxString&
> wxstr)
> {
> #ifdef __WXGTK__
>      wxCharBuffer
> buffer(wxConvUTF8.cWC2MB(wxstr.wc_str(*wxConvCurrent))); // skieu
> #else
>      wxCharBuffer buffer(wxstr.mb_str(*wxConvCurrent));
> #endif
>
>      if ((buffer.data() == NULL) && !wxstr.IsEmpty())
>          buffer = wxConvertWX2MB(wxstr.c_str()); // old way that mostly
> works
>
>      return buffer;
> }
> ---------------------------------------------------------
>

The more I read about Unicode it seems like this is all we need.
http://www.wxwidgets.org/manuals/stable/wx_wxstring.html#wxstring
http://www.wxwidgets.org/manuals/stable/wx_unicode.html#unicode
http://www.wxwidgets.org/manuals/stable/wx_mbconvclasses.html#mbconvclasses
http://www.wxwidgets.org/manuals/stable/wx_wxmbconv.html#wxmbconv

WXDLLIMPEXP_WXLUA wxString lua2wx(const char* luastr)
{
    return wxString(luastr, *wxConvCurrent);
}

const WXDLLIMPEXP_WXLUA wxCharBuffer wx2lua(const wxString& wxstr)
{
    wxCharBuffer buffer(wxstr.mb_str(*wxConvCurrent));
    return buffer;
}

Hakkı, could you try these and let me know if they work.

Regards,
    John
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to