wxString & it's length
Vaclav Slavik
vslavik at fastmail.fm
Thu Mar 6 06:36:49 PST 2008
Steven Van Ingelgem wrote:
> the Len() is implemented as "length()", which is implemented as
> "end() - begin()"... Which is the amount of bytes between the end
> and beginning if I understand correctly.
You don't, it's the distance of the iterators in *characters* on the
trunk -- and UTF-8 build doesn't exist in 2.8, so I assumed you're
talking about the trunk. It's the number of bytes only in 2.8's ANSI
build and that's because it didn't make the distinction between bytes
and characters.
> Am I correct in that?
Once again, no.
> > This will change before 2.9.0.
>
> You mean 3.0.0 ( I thought odd numbers were development releases )?
No, I meant 2.9.0 -- the first development release before wx3.
> Is there any other way I can get out the data + it's length from
> wxString or any other class?
You never defined what exactly you want. The length in characters is
length() and that's what you seemed to want. If that's not the case
and you do use embedded NULs (because otherwise it's trivial: just
use strlen() or wcslen() on mb_str() or wc_str() return value), then
you can for example get raw wchar_t* data:
const wxWX2WCbuf data = str.wc_str();
size_t dataLen = str.length();
(this is compatible with wx2.8 too; and it works because
wxString::length() equals the length of wchar_t* representation of
the string)
Vaclav
--
PGP key: 0x465264C9, available from http://pgp.mit.edu/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.wxwidgets.org/pipermail/wx-users/attachments/20080306/f59585a7/attachment.pgp
More information about the wx-users
mailing list