RAD Studio
ContentsIndex
PreviousUpNext
Enabling C++ Applications for Unicode

C++ has a unique set of Unicode-related issues that Delphi users do not have. Some of these issues are:

  • String constants, such as "string constant", are still narrow (char*), so you cannot pass them to VCL functions that take PChar as you did before. If you prefix the constant with L, as in L"string constant", you can pass the constant to VCL functions with a PChar parameter.
  • The C++ RTL is as wide and narrow as it always was. Unless you planned ahead and used <tchar.h> and the _txxxxxx() macros, you need to do some work to use the wide flavor of the RTL. VCL generally uses wide string data, so you probably need to use wide RTL functions.
  • The Windows API is still narrow by default. The new _TCHAR mapping option helps trememdously here, but the option is OFF by default. You need to explicitly set the _TCHAR maps to option on the ProjectOptionsDirectories and Conditionals dialog box.
  • You can set the codepage for AnsiString types with AnsiStringT<codepage>. The same predefined types are available that Delphi provides:
    • AnsiString is AnsiStringT<0>
    • UTF8String is AnsiStringT<65005>
    • RawByteString is AnsiStringT<0xFFFF>

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!