Re: Are _T() and TEXT() macros equivalent?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



David Ching wrote:

Deplorable = the user was too lazy to type in the _T() around the string :o)


Absolutely amazing to me that some of the most practical and useful things are considered deplorable by others.

Joking apart, I would say that the vast majority of the uses of the automatic conversion from narrow to wide string are with hard coded strings where the programmer simply forgot to use _T("").

True story: In my copy of VC6, I modified the CString headers to remove the conversion constructors and assignments. This allowed me to catch many errors in my hybrid UTF8/UTF16 application. Some time later, I tried to make a Unicode build of Ultimate ToolBox and Ultimate Grid. Dozens of errors, all but one of which involved failure to use _T(""). The _T("") idiom was used correctly in other places.

Is this automatic conversion useful? I really don't think so. It just leads to a situation where it is possible to omit _T() (or L) in some places but not others. Soon the ANSI code page will be gone, and hybrid UTF16/UTF8 applications may become more common, and the automatic conversion will do the wrong thing (AFAIK, it is not possible to set the code page to be UTF8).

--
David Wilkinson
Visual C++ MVP
.



Relevant Pages

  • String^, const char*, std::string, and c_str( )
    ... Therefore adopting the ... Much of our managed code is concerned with interfacing to native C++ code ... In Managed C++ there was an automatic conversion between ... a std::string or a String^. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: getting a form field to default to the value entered in the last record
    ... >concatenating the double quotation marks before and after Me.textbox? ... The DefaultValue property is a string. ... makes the right guess in its automatic conversion process. ...
    (microsoft.public.access.formscoding)
  • Re: getting a form field to default to the value entered in the last record
    ... >concatenating the double quotation marks before and after Me.textbox? ... The DefaultValue property is a string. ... makes the right guess in its automatic conversion process. ...
    (microsoft.public.access.forms)
  • Re: Are _T() and TEXT() macros equivalent?
    ... Deplorable = the user was too lazy to type in the _Taround the string:o) ... "David Ching" wrote in message ... automatic conversion feature of CString. ...
    (microsoft.public.vc.mfc)
  • Re: SetString
    ... D4 does automatic conversion it creates a new WideString up to the ... pWC:PWideChar; ... // Automatic conversion to Ansi String ...
    (comp.lang.pascal.delphi.misc)