Share via


Working with Surrogate Pairs (Windows CE 5.0)

Send Feedback

Windows CE handles surrogates as pairs of 16-bit code values. The system processes surrogate pairs in a way similar to the way it processes non-spacing marks. At display time, the surrogate pair display as one glyph. Applications automatically support surrogates if they support Unicode and use system controls and standard APIs, such as ExtTextOut and DrawText. Thus, if your code uses standard system controls or uses general ExtTextOut-type calls to display, surrogate pairs should work without any changes necessary.

Because surrogates are well defined, you can also write your own code to handle surrogate text processing. When a program encounters a separated Unicode value from either the lower reserved range or the upper reserved range, it must be one half of a surrogate pair. Thus, you can detect a surrogate pair by doing simple range checking. If you encounter a Unicode value in the lower or upper range, then you need to track backward or forward one 16-bit width to get the rest of the character. Keep in mind that CharNext and CharPrev move by 16-bit code points, not by surrogates.

Since surrogate support is limited to handling and display, set any edit control used in your application that will display such content to Read Only.

For sorting, all surrogate pairs are treated as two Unicode code points. Surrogates are sorted after other Unicode code points, but before the PUA (private user area). Sorting for a standalone surrogate character (that is, either the high or low character is missing) is not supported.

See Also

Graphics Device Interface (GDI) | ExtTextOut | DrawText | CharNext | CharPrev | Working With Unicode Surrogates

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.