Re: TCHAR * to WCHAR*




"Giovanni Dicanio" <giovanni.dicanio@xxxxxxxxxx> wrote in message
news:uSppv34NIHA.5860@xxxxxxxxxxxxxxxxxxxxxxx

"Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx> ha scritto nel messaggio
news:umT%23hM3NIHA.6108@xxxxxxxxxxxxxxxxxxxxxxx

fn_name ((std::wstring("Error: ") + T2W(err.ErrorMessage()).c_str ());

missing L -- should be std::wstring(L"Error: ")

So ATL/MFC CString (or CStringW) seems smarter than std::wstring, because
CString has a constructor which takes a narrow character string and
converts to CString's type, without using the L or _T() decorator.

Why would you want a runtime conversion for a string literal? That's asking
for trouble, because it's likely to be user-preference dependent, in which
case, why use Unicode at all?


Giovanni




.



Relevant Pages

  • Re: TCHAR * to WCHAR*
    ... So ATL/MFC CString seems smarter than std::wstring, ... CString has a constructor which takes a narrow character string and converts ...
    (microsoft.public.vc.language)
  • Re: CString Speed and compiler optimization
    ... Empty checks for a few things and does a bit of stuff to release, or not, ... why this interest in what the optimiser does. ... has no way to know that a CString is initialised, in its constructor, to ...
    (microsoft.public.vc.mfc)
  • Re: CString not working as advertised
    ... The following will not compile in a UNICODE application: ... CString kindOfFruit; ... Rather, the compiler should first construct a temporary CString using the const char* constructor, and then initialize kindOfFruit using the copy constructor. ... none of the CStringT constructors is explicit. ...
    (microsoft.public.vc.mfc)
  • Re: TREE structure in MFC, how, where and why?
    ... I had not noticed the CString. ... >By using malloc, the constructor on your CString is not being called. ... >>terminal node and a tree node is that a terminal node has no children. ...
    (microsoft.public.vc.mfc)
  • Re: CObject
    ... // the CObject header ... CString address, ... // Default Constructor CLeagueEstab ...
    (microsoft.public.vc.mfc)