From: John L. <jla...@gm...> - 2006-07-18 22:22:38
|
On 7/9/06, Steve Kieu <ha...@ya...> wrote: > > Hi all, Sorry about the delay, I was out of the country on work. > I have fixed the unicode problem (my previous post) by changing: Where did you get the Unicode string that doesn't work in your sample program? Could you post one? I tried different things in wxGTK compiled in Unicode, but I had no problem with the original conversion code. I am not expereienced with Unicode so the original code was from some posts on wx-users and the STC contrib about how to convert back and forth. Do we also need to care about embedded NULLS? There is a lua function to get the string as well as it's length, maybe we should use that too? Perhaps the unicode string had embedded NULLs? > in wxLua/modules/wxlua/include/wxlstate.h function lua2wx > and wx2lua like below > > inline WXDLLIMPEXP_WXLUA wxString lua2wx(const char* luastr) > { > if (luastr == NULL) > return wxEmptyString; > #if wxUSE_UNICODE > return wxString(luastr, wxConvUTF8); > #else > return wxString(wxConvUTF8.cMB2WC(luastr), *wxConvCurrent); > #endif > //return wxConvertMB2WX(luastr); // this fails on NULL > } Always wxConvUTF8 in Unicode? Not wxConvCurrent? I don't understand why in non unicode you convert it to a WC array and then back. You should be able to just to "return wxString(luastr)" since everything is ASCII. > inline const WXDLLIMPEXP_WXLUA wxCharBuffer wx2lua(const wxString& wxstr) > { > //wxCharBuffer buffer(wxConvertWX2MB(wxstr.c_str())); // origin > // wxCharBuffer buffer=wxstr.mb_str(wxConvUTF8); // skieu > wxCharBuffer buffer=wxConvUTF8.cWC2MB(wxstr.wc_str(*wxConvCurrent)); // > skieu > return buffer; > } Originally: wxConvertWX2MB == wxConvCurrent->cWX2MB(wchar_t* s) cWX2MB returns wxUSE_UNICODE ? cWC2MB(wchar_t* psz) : psz So again, always use wxConvUTF8? > Any comment on it? It fixes the problems for me and not create more problem > in Linux. Have not tested with non unicode built of wxWidgets though. I > still do not know why the problem happend in win32 only, I will try it in MSW in non unicode tomorrow and GTK w/ unicode tonight. Thanks, John Labenski > ---------- Forwarded message ---------- > From: Steve Kieu <ha...@ya...> > To: wxl...@li... > Date: Sun, 9 Jul 2006 07:55:27 +1000 (EST) > Subject: wxString, Unicode problem .... > Hi everyone, > > I found a problem in win32 wrt unicode things. My test program is simple a > multiline text widgets ; cut and paste a unicode text into the widgets and > display the value using GetValue() by wx.wxMesasgeBox. In Linux it is > working as expected. But in win2k, winXP , win98, it does not display > anything pssibly the value is nil. If the text is not unicoded then it > displayed correctly. > > Wxwidgets in win32 compiled with unicode support and mslu support. Normal wx > apps is fine. > > wxLua is the snapshot wxLua_Snapshot_2006-06-21.tar.gz > > Is it a known problem and has been fixed in the current snapshot ? How to > debug (if it is a bug then ) > > The following is the code smaple > > > f=wx.wxFrame(wx.wxNull, -1, "") > s0=wx.wxBoxSizer(wx.wxVERTICAL) > f:SetSizer(s0) > text=wx.wxTextCtrl(f, 10004, "", wx.wxDefaultPosition, wx.wxDefaultSize, > wx.wxTE_MULTILINE) > b0=wx.wxButton(f, 10000, "Display") > s0:AddWindow(text) > s0:AddWindow(b0) > > f:Connect(-1, wx.wxEVT_COMMAND_BUTTON_CLICKED, function (e) > > wx.wxMessageBox(text:GetValue()) > > end) > > f:Show(true) > > Cheers, > > > > S.KIEU > > Send instant messages to your online friends http://au.messenger.yahoo.com > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > > _______________________________________________ > Wxlua-users mailing list > Wxl...@li... > https://lists.sourceforge.net/lists/listinfo/wxlua-users > > > |
From: Steve K. <ha...@ya...> - 2006-07-19 22:16:03
|
Hi John, The sample is very simple. You create any frame with a text widgets on it, Enable wxTE_RICH and wxTE_RICH2 as well. Add some code to display the getvalue of the text widget and display it using wx.wxMessageBox for example. You will get null (nothing displayed) The unicode sample you can get from this site http://vnexpress.net/ just copy some text there and paste. -- Sample code f=wx.wxFrame(wx.wxNull, -1, "") s0=wx.wxBoxSizer(wx.wxVERTICAL) f:SetSizer(s0) idtext=wx.wxID_HIGHEST+1 text=wx.wxTextCtrl(f, idtext, "", wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxTE_MULTILINE+wx.wxTE_RICH+wx.wxTE_RICH2) b0=wx.wxButton(f, 10000, "Display") s0:AddWindow(text) s0:AddWindow(b0) f:Connect(-1, wx.wxEVT_COMMAND_BUTTON_CLICKED, function (e) wx.wxMessageBox(text:GetValue() ) end) f:Show(true) -- end sample code The problem only happened in win32 (all window version). Linux GTK is fine which make me think it is a bug in the wxWidget conversion code in win32. Actually I did not find errors in the old code, but in wxWidgets we just have too many ways of doing such conversions and the old wxLua code is not the same as the code I usually using in my apps which proves to work fine (I have had lots of strange problem in these conversion things until I found a reliable way of doing such conversion) So I replace it with my code and it works as expected. John Labenski <jlabenski@g Where did you get the Unicode string that doesn't work in your sample program? Could you post one? I tried different things in wxGTK compiled in Unicode, but I had no problem with the original conversion Yeah as I said, only happen in win32. Do we also need to care about embedded NULLS? There is a lua function to get the string as well as it's length, maybe we should use that too? Perhaps the unicode string had embedded NULLs? The sample in the website I said before is Vietnamese text ; coding using standard UTF-8, not quite sure if it contain NULL but I guess not. > #if wxUSE_UNICODE > return wxString(luastr, wxConvUTF8); The above part is tested as I use the unicode built of wxWidgets > #else > return wxString(wxConvUTF8.cMB2WC(luastr), *wxConvCurrent); Always wxConvUTF8 in Unicode? Not wxConvCurrent? Have not tested in non Unicode built of wxWidgets. but in this case I gues it will use wxMBConv.cMB2WC or wxConvLibc.cMB2WC. So this part should change accordingly (it may even work without changes but let me test in non unicode built first) I don't understand why in non unicode you convert it to a WC array and then back. You should be able to just to "return wxString(luastr)" since everything is ASCII. Even wxWidgets is built without unicode support but the string we get it might contain unicode chars so it is not pure ASCII. Cheers, S.KIEU --------------------------------- On Yahoo!7 Messenger: Make free PC-to-PC calls to your friends overseas. |
From: Steve K. <ha...@ya...> - 2006-07-20 00:07:55
|
Hi, Have built the non unicode os wxWidgets and wxLua and have no problem with it (the new conversion code) Cheers, S.KIEU --------------------------------- The LOST Ninja blog: Exclusive clues, clips and gossip. |
From: John L. <jla...@gm...> - 2006-07-20 16:13:48
|
On 7/19/06, Steve Kieu <ha...@ya...> wrote: > > Hi, > > Have built the non unicode os wxWidgets and wxLua and have no problem with > it (the new conversion code) Thanks for the fix, I've just tried it in non unicode MSW and it works fine. It committed now. Thanks, John Labenski |