smo
smo

Reputation: 185

wxWidgets: wxString encode using wxCSConv wxMBConv

I want to encode a .html file (wxString) into hex. I tried to achieve this by

data = wxString((const char*)html_stuff, wxCSConv(wxFONTENCODING_UTF8), sizeof (html_stuff));

Thank you!

Upvotes: 0

Views: 925

Answers (1)

ravenspoint
ravenspoint

Reputation: 20536

The code you posted is converting from UTF8 to unicode

http://docs.wxwidgets.org/2.9.2/classwx_string.html#86a2ec232912c97ed44ba34651d98123

UTF8 uses 1 to 3 bytes to encode each character - it is used to send documents in HTML so browsers can display them. Unicode uses 2 bytes to encode every character - it is used by wxString.

My guess is that what you want to do is convert a unicode wxString to UTF8. There are lots of different ways to do that. The 'best' way depends on several things. The simplest would be to use wxString::mb_str() http://docs.wxwidgets.org/2.8.9/wx_wxstring.html#wxstringmbstr

I recomend that you learn something about character encoding. Here is a link to my take on it.

Upvotes: 1

Related Questions