On 12/6/06, Hakki Dogusan <[EMAIL PROTECTED]> wrote:
> John Labenski wrote:
> > On 12/5/06, Hakki Dogusan <[EMAIL PROTECTED]> wrote:
> >> (Mingw, wxLua cvs, wx2.7.2/wx2.8 ANSI and Unicode, WinXP Turkish)
> >>
> >> I can't use Turkish chars (ie. ğüşiöçı ĞÜŞİÖÇİ) in label, title, etc.
> >>
> >> If I change the following functions to old implementation, it works:
> >> lua2wx, wx2lua.
> >
> > Please see this message
> > Re: [Wxlua-users] wxString, Unicode problem .... (Fixed,) Steve Kieu
> > http://www.mail-archive.com/wxlua-users@lists.sourceforge.net/index.html#00692
> >
> > // Convert a 8-bit Lua String into wxString
> > inline WXDLLIMPEXP_WXLUA wxString lua2wx(const char* luastr)
> > {
> >     if (luastr == NULL) return wxEmptyString; // check for NULL
> >
> > #if wxUSE_UNICODE
> >     return wxString(luastr, wxConvUTF8);
> > #else
> >     return wxString(wxConvUTF8.cMB2WC(luastr), *wxConvCurrent);
> > #endif // wxUSE_UNICODE
> >
> >   //return wxConvertMB2WX(luastr); // old way that mostly works
> > }
> >
> > // Convert a wxString to 8-bit Lua String
> > inline const WXDLLIMPEXP_WXLUA wxCharBuffer wx2lua(const wxString& wxstr)
> > {
> >     //wxCharBuffer buffer(wxConvertWX2MB(wxstr.c_str())); // old way
> > that mostly works
> >     wxCharBuffer
> > buffer(wxConvUTF8.cWC2MB(wxstr.wc_str(*wxConvCurrent))); // skieu
> >     return buffer;
> > }
> >
> > ====================================
> >
>
> If I'm not mistaken stc uses UTC2 internally. So using stc's conversion
> functions may not help here. Instead, I tested using FlameRobin's
> (www.flamerobin.org) functions from StringUtils.h;
> std::string wx2std(const wxString& input, wxMBConv* conv=wxConvCurrent);
> wxString std2wx(const std::string& input, wxMBConv* conv=wxConvCurrent);

Humm, interesting... see below.

> Changed lua2wx, wx2lua and wxLuaCharBuffer's ctor as follows:
>
> inline WXDLLIMPEXP_WXLUA wxString lua2wx(const char* luastr)
> {
>      if (luastr == NULL) return wxEmptyString; // check for NULL
>      return wxString(luastr, *wxConvCurrent);
> }

The old way of doing the conversion did it this way.

//return wxConvertMB2WX(luastr); // old way that mostly works
#define wxConvertMB2WX(s)   wxConvCurrent->cMB2WX(s)

This is the code for the wxString function which does the same as wxConvertMB2WX
wxString::wxString(const char *psz, const wxMBConv& conv, size_t nLength)
{
...
      wxWCharBuffer wbuf = conv.cMB2WC(psz, nLength, &nLenWide);

==================
I see that we have 3 different ways to convert the strings. Which way
is "right" for all cases.

1) doesn't work for some unknown cases
    wxConvertMB2WX == wxConvCurrent->cMB2WX(s) ==
wxConvCurrent->cMB2WC

2) Doesn't work for Turkish (and undoubtedly others)
#if wxUSE_UNICODE
    return wxString(luastr, wxConvUTF8);
#else
    return wxString(wxConvUTF8.cMB2WC(luastr), *wxConvCurrent);
#endif // wxUSE_UNICODE

3) new? works?
    wxString(luastr, *wxConvCurrent); ==
    wxWCharBuffer wbuf = conv.cMB2WC(psz, nLength, &nLenWide);


The differences I see is that



> inline const WXDLLIMPEXP_WXLUA wxCharBuffer wx2lua(const wxString& wxstr)
> {
>      wxCharBuffer buffer(wxstr.mb_str(*wxConvCurrent));
>      return buffer;
> }
>
> wxLuaCharBuffer(const wxString &wxstr) : m_buffer((const char *)NULL)
> {
>      m_buffer = wxCharBuffer(wxstr.mb_str(*wxConvCurrent));
> }
>
>
> I tested with wxUSE_UNICODE=1 and =0 configurations.
>
> I can use Turkish characters now.
>
> (Mingw, wxLua cvs, wx2.8 ASCII and Unicode, WinXP Turkish)
>
>
> ps. Thank you for working hard on wxLua!
>
>
> --
> Regards,
> Hakki Dogusan
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> wxlua-users mailing list
> wxlua-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wxlua-users
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to