Re: CString not working as advertised
- From: "Tom Serface" <tserface@xxxxxxx>
- Date: Thu, 20 Apr 2006 08:24:51 -0700
Hi David,
I think the bigger issue with this is that it uses the ACP code page
(whatever is set) to do the conversion to multi-byte so you don't always get
a clean conversion. However, to be fair, I find the conversion feature to
be pretty handy at times when I know I am not doing something that would
mangle my strings. You're right though, it doesn't produce any error
message during compile. That makes me wonder how the OP got this error when
he was compiling.
Tom
"David Wilkinson" <no-reply@xxxxxxxxxxxx> wrote in message
news:%23w1CH%23FZGHA.1016@xxxxxxxxxxxxxxxxxxxxxxx
Joseph M. Newcomer wrote:
On Wed, 19 Apr 2006 15:06:53 -0400, R. Christian Call[snip]
<rccall@xxxxxxxxxxxxxx> wrote:
[snip]
The examples given in the MFC library fail miserably most fo the time--
even for simple stuff that I'd expect to work without a hitch. For
instance, I can't do this:
CString kindOfFruit = "bananas";
****
Note that default for VS 2005 is Unicode, so a quoted string like above
is meaningless.
You could either write
CStringA kindOfFruit = "bananans";
or
CStringW kindOfFruit = L"bananas";
or
CString kindOfFruite = _T("bananas");
but what you wrote should not compile, and the error message below is
what you should get.
****
Joe:
That's interesting, but I disagree. In VC6, and I think VC7, in a UNICODE
build
CString kindOfFruit = "bananas";
will actually compile, because CString contains "conversion constructors"
which will initialize a CString from either narrow or wide
characters in both ANSI and UNICODE build.
IMO, this is a terrible feature, because (like most automatic conversions)
it prevents the compiler from type-checking the code. But I find it hard
to believe that MS would have removed this feature from VC8, because much
code (not mine!) relies on this feature to convert between narrow/wide
character strings.
David Wilkinson
.
- Follow-Ups:
- Re: CString not working as advertised
- From: David Wilkinson
- Re: CString not working as advertised
- References:
- CString not working as advertised
- From: R . Christian Call
- Re: CString not working as advertised
- From: Joseph M . Newcomer
- Re: CString not working as advertised
- From: David Wilkinson
- CString not working as advertised
- Prev by Date: Re: Popup menu problem
- Next by Date: Re: CString not working as advertised
- Previous by thread: Re: CString not working as advertised
- Next by thread: Re: CString not working as advertised
- Index(es):
Relevant Pages
|