wxConvUTF8.cWX2MB

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ioio
Experienced Solver
Experienced Solver
Posts: 61
Joined: Tue May 24, 2005 9:46 am

wxConvUTF8.cWX2MB

Post by ioio » Fri Jan 06, 2006 3:45 pm

This mays be simple but the documentation doesn't answer on that.

This piece of code has been compiled in UNICODE

Code: Select all

wxString str;
// .... we fill str
const char *buffer = wxConvUTF8.cWX2MB( str );
/// ...
Does the buffer have to be freed with free() ?

chris
I live to help wx-kind
I live to help wx-kind
Posts: 150
Joined: Fri Oct 08, 2004 2:05 pm
Location: Europe

Post by chris » Sun Jan 08, 2006 1:01 pm

Hi ioio,

there are two possible scenarios:

You call cWX2MB() in an ansi build. You'll then get back the parameter unaltered.

Or you call cWX2MB() in an Unicode build. You'll then get back a wxCharBuffer, which is an object that can be cast to (const char*). That buffer will be defined as long as the wxCharBuffer object doesn't lose scope, i.e. the surrounding block

Code: Select all

{ // begin block

wxString str;
const char *buffer = wxConvUTF8.cWX2MB( str );

} // end block, losing scope here.
isn't left. To make a long story short: No, you don't have to free it ;)

HTH, Chris
this->signature=NULL;

Post Reply