Copying the contents of a wxString
Iulian-Nicu Serbanoiu
undergraver at gmail.com
Fri Sep 8 15:45:48 PDT 2006
( wxString::Len() + 1 ) * sizeof(wxChar). That's unicode
representation, as wxChar can represent any character from the unicode
tables.
Your buffer could be wxChar * ( or char * if you want all contents ).
wxString str;
...
int wxchar_len = str.Len()+1;
wxChar * buf = new wxChar[wxchar_len];
memcpy(buf,str.c_str(),wxchar_len*sizeof(wxChar) );
// and
int char_len = wxchar_len*sizeof(wxChar)/sizeof(char);
char * buf = new char[char_len];
memcpy( buf , str.c_str() , char_len*sizeof(char) );
Hope this correct,
Iulian
On 9/8/06, Peter Gordon <peter at pg-consultants.com> wrote:
> I need to copy the contents of a wxString to a separate, non-wxString
> buffer.
>
> The pointer is wxString::c_str(), but what is the length that needs to
> be copied assuming that I am using Unicode? Do I need to take
> wxString::Len(),
> wxString::Len() * sizeof(w_char),
> wxString::Len() * sizeof(w_char) + 1,
> or what?
>
> Thanks,
>
> Peter
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
>
More information about the wx-users
mailing list