Hi, 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. > > The characters you sent above work in the title of a wxFrame in wxLua > compiled in Linux, unicode w/ gcc. So it's a problem in MSW. I also > checked with some other chars on this page. > http://www.columbia.edu/kermit/utf8.html > > The code I think you're talking about is below. Things were changed to > fix unicode strings in MSWindows. > > 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; > } > > > ==================================== > > I have asked about conversions on wx-users a long time ago and didn't > get a concrete answer as to the single best way to do it. The old way > is copied from the functions wx2stc and stc2wx that were used in the > wxStyledTextCtrl, however more recent versions use the string > conversion funcions that are part of Scintilla, see > wxWidgets/contrib/src/stc/scintilla/src/UniConversion.cxx. > > Could you try to replace the code in wx2lua and lua2wx with wx2stc and > stc2wx. You'll have to #include "wx/stc/stc.h". Please let us know if > it works. > > > Hopefully Steve Kieu will read this and chime in since he seems pretty > familiar with unicode strings. > > Regards, > John Labenski
(Sorry for not joining to unicode discussions; I don't know it well. I'm following wxLua since the beginning, but only recently I decide to write a program with it.) 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); 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); } 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