Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

ID: 26658, Widechar sets for Unicode

by Peter Below Email: Anonymous

Implements sets of widechars to replace the use of classic set of chars in Delphi 2009 and later.
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 12.0  to 14.0 508 downloads
Copyright: No significant restrictions

Size: 273,008 bytes
Updated on Sun, 29 Nov 2009 02:10:15 GMT
Originally uploaded on Fri, 13 Feb 2009 04:56:34 GMT
SHA1 Hash: 20138346EF4C419F3024D2D56C3EC7202CA33A61
MD5 Hash: 48A2402CA0DBEEA7A8EF4750F213B43F

    Explore the files in this upload

Delphi 2009 has finally moved to Unicode, so the standard String type is now a Unicode string and Char is a wide character (16 bit). One of the victims of this change is the good old practice of validating input by using constructs like

if Key In ['0'..'9'] then

Since a set in Delphi can at most have 256 members sets of Char are no longer possible, instead the set referenced above will be compiled as a set of Ansichar (TSysCharset) and the code (with Key typed as Char) will generate a warning. It will still work as long as Key is in the range #0 to #127 (the 7-bit ASCII range) but the results are basically undefined if this is not the case.

So, what can we use as equivalent? Delphi offers the CharInSet function that will at least suppress the warning but it will also unconditionally return False for all characters above #127. That may serve for US americans but certainly not for the rest of the world <g>.

The WidecharSetU unit supplied in this archive aims to solve this problem by implementing the equivalent of a set of widechar. The syntax in using these is necessarily a bit different from using the classic sets, since there is no build-in compiler support for my "widechar set" types and the language also does not support operator overloading on interface types (which I have choosen as the base for the implementation).

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03