Enabling C++ Applications for Unicode

From RAD Studio
Jump to: navigation, search

Go Up to Unicode for C++ Index

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. You can pass the constant to VCL functions with a PChar parameter if you prefix the constant with L, as in:
L"string constant"
  • 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 typically 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 Project > Options > Directories 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>

See Also

Personal tools
Newest Version: XE
In other languages