Re: CString and UTF-8
- From: "Tom Serface" <tserface@xxxxxxx>
- Date: Tue, 19 Dec 2006 08:04:55 -0800
So far as I can tell from the source of GetLength() it simple returns the
number of characters divided by the size of a character (overall) so I'm
guessing it is unreliable and I haven't counted on it for some time to
contain the correct length. Converting strings to UTF-16 (assuming no
surrogates are involved) makes the task a lot easier and CString seems to
know how to work with those strings just fine.
Tom
"David Wilkinson" <no-reply@xxxxxxxxxxxx> wrote in message
news:%232ZkYq1IHHA.780@xxxxxxxxxxxxxxxxxxxxxxx
Mr Asm:
This is what I meant by my previous statement. In this sense, CString does
not understand MBCS with the local code page either.
The only important sense in which CString "supports" MBCS (in ANSI build)
is that if you pass it to an API like SetWindowText() then the OS will
display the string correctly if it is a correct MBCS string in the local
code page. But this is not a property of CString, it is a property of the
OS.
To my knowledge, the only things CString knows about MBCS are
1. It has conversion constructors from UTF-16 that use the local MBCS code
page (a VERY bad feature, IMHO).
2. Methods like CString::Compare() which can return a failure code if
either of the strings is not valid.
Other than that, as Joe says, it's just a container for passing bytes
around. Just like std::string.
David Wilkinson
.
- References:
- Re: CString and UTF-8
- From: MrAsm
- Re: CString and UTF-8
- From: Joseph M . Newcomer
- Re: CString and UTF-8
- From: MrAsm
- Re: CString and UTF-8
- From: David Wilkinson
- Re: CString and UTF-8
- Prev by Date: Re: How make an Accelerator key work regardless of which control has fokus?
- Next by Date: Re: How make an Accelerator key work regardless of which control has fokus?
- Previous by thread: Re: CString and UTF-8
- Next by thread: Re: CString and UTF-8
- Index(es):
Relevant Pages
|