On 7/9/06, Steve Kieu <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
> To: wxlua-users@lists.sourceforge.net
> 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
> 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