Take the 2-minute tour ×

I am wondering: SizeOf(Char) = 2 in never Delphi versions, but this is not enough to store all integer mappings for characters defined in unicode table, right? (As far as I know there is more characters than 65536). So how this problem is solved?

Maybe two bytes are used to encode all characters from Basic Multilingual Plane (BMP)? But what happens with characters from outside the BMP?

Could someone sheed light on this?


share|improve this question
They're windows wide characters (wchar_t) which is is 16-bit for compatibility. Characters outside that are encoded using UTF-16 –  Petesh Aug 22 '12 at 17:15
Due to the surrogate Unicode feature, you are never sure that an Unicode glyph in the BMP will be coded within one UCS4 mapped character. So this is not a problem to use UTF-16 encoding, just like everywhere in Windows. –  Arnaud Bouchez Aug 22 '12 at 17:16
en.wikipedia.org/wiki/UTF-16 –  user246408 Aug 22 '12 at 17:19

2 Answers 2

Strings outside BMP are encoded with surrogates, as in UTF-16.

share|improve this answer
Delphi 2009/2010/XE/XE2/XE3 Char = WideChar, using the UTF-16 encoding, as the Windows API. If you want true Unicode process, you will need to use a string anyway, due to the surrogate feature. –  Arnaud Bouchez Aug 22 '12 at 17:14
@Arnaud what do you mean by "true Unicode process"? That final sentence is not clear to me. –  David Heffernan Aug 22 '12 at 19:05
I've read the link given by @Serg and I don't get the concept of surrogates. Why to use them if there are planes? –  Wodzu Aug 23 '12 at 10:27
Without surrogate pairs you can't encode all of the Unicode space in a 16 bit char. –  David Heffernan Aug 23 '12 at 15:41

Before, if you wanted to store a single character, you could use one single Char (AnsiChar). But in Unicode, you should not be storing single UTF-16 code points in Chars (which are WideChars, in D2009+), you should be using strings, as these can contain a single Char as well as a surrogate pair.

share|improve this answer
"Before, if you wanted to store a single character, you could use one single Char (AnsiChar)." That was not always true if you had to deal with MBCS ansi strings, which could use multiple AnsiChar values for a single Unicode character. –  Remy Lebeau Aug 23 '12 at 1:04

Your Answer


