Wide strings are used in a variety of situations. Some technologies, such as XML, use wide strings as a native type. You may also choose to use wide strings because they simplify some of the string-handling issues in applications that have multiple target locales.

Using a wide character encoding scheme has the advantage that you can make many of the usual assumptions about strings that do not work for MBCS systems. There is a direct relationship between the number of bytes in the string and the number of characters in the string.

You do not need to worry about cutting characters in half or mistaking the second part of a character for the start of a different character. A disadvantage of working with wide characters is that many VCL controls represent string values as single byte or MBCS strings. (Cross-platform versions of the controls typically use wide strings.)

Translating between the wide character system and the MBCS system every time you set a string property or read its value can require tremendous amounts of extra code and slow your application down.

However, you may want to translate into wide characters for some special string processing algorithms that need to take advantage of the 1:1 mapping between characters and WideChars. The following functions convert between standard single-byte character strings (or MBCS strings) and Unicode strings:

StringToWideChar

WideCharLenToString

WideCharLenToStrVar

WideCharToString

WideCharToStrVar

In addition, the following functions translate between WideStrings and other representations:

UCS4StringToWideString

WideStringToUCS4String

VarToWideStr

VarToWideStrDef

The following routines work directly with WideStrings:

WideCompareStr

WideCompareText

WideSameStr

WideSameText

WideSameCaption (CLX applications only)

WideFmtStr

WideFormat

WideLowerCase

WideUpperCase

Finally, some routines include overloads for working with wide strings: