discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSCharacterSet issues...


From: Lloyd Dupont
Subject: NSCharacterSet issues...
Date: Wed, 16 Aug 2006 14:55:30 +1000

I'm porting some MacOSX code to to Windows.
At some stage we are removing: [NSCharacterSet illegalCharacterSet] and [NSCharacterSet controlCharacterSet] from our strings.

While it worked on the Mac, with the GNUstep implementation on Windows It removed all my chineese characters!

So I wrote a fix I'm submitting back.
I went to this web site:
http://www.fileformat.info/info/unicode/category/index.htm

And used:
http://www.fileformat.info/info/unicode/category/Cc/list.htm
http://www.fileformat.info/info/unicode/category/Cf/list.htm
for controlCharacterSet
and
http://www.fileformat.info/info/unicode/category/Cn/index.htm
for illegalCharacterSet

which gave me an empty illegalCharacterSet
and the following for controlCharacterSet

static NSMutableCharacterSet * controlCharacterSet()
{
static NSMutableCharacterSet * set = nil;
if ( !set ) {
 set = [[NSMutableCharacterSet alloc] init];

[set addCharactersInRange: NSMakeRange(0x070F , 1)];
[set addCharactersInRange: NSMakeRange(0x17B4 , 1)];
[set addCharactersInRange: NSMakeRange(0x17B5 , 1)];
[set addCharactersInRange: NSMakeRange(0x200B , 1)];
[set addCharactersInRange: NSMakeRange(0x200C , 1)];
[set addCharactersInRange: NSMakeRange(0x200D , 1)];
[set addCharactersInRange: NSMakeRange(0x200E , 1)];
[set addCharactersInRange: NSMakeRange(0x200F , 1)];
[set addCharactersInRange: NSMakeRange(0x202A , 1)];
[set addCharactersInRange: NSMakeRange(0x202B , 1)];
[set addCharactersInRange: NSMakeRange(0x202C , 1)];
[set addCharactersInRange: NSMakeRange(0x202D , 1)];
[set addCharactersInRange: NSMakeRange(0x202E , 1)];
[set addCharactersInRange: NSMakeRange(0x2060 , 1)];
[set addCharactersInRange: NSMakeRange(0x2061 , 1)];
[set addCharactersInRange: NSMakeRange(0x2062 , 1)];
[set addCharactersInRange: NSMakeRange(0x2063 , 1)];
[set addCharactersInRange: NSMakeRange(0x206A , 1)];
[set addCharactersInRange: NSMakeRange(0x206B , 1)];
[set addCharactersInRange: NSMakeRange(0x206C , 1)];
[set addCharactersInRange: NSMakeRange(0x206D , 1)];
[set addCharactersInRange: NSMakeRange(0x206E , 1)];
[set addCharactersInRange: NSMakeRange(0x206F , 1)];
[set addCharactersInRange: NSMakeRange(0xFEFF , 1)];
[set addCharactersInRange: NSMakeRange(0xFFF9 , 1)];
[set addCharactersInRange: NSMakeRange(0xFFFA , 1)];
[set addCharactersInRange: NSMakeRange(0xFFFB , 1)];
[set addCharactersInRange: NSMakeRange(0x1D173 , 1)];
[set addCharactersInRange: NSMakeRange(0x1D174 , 1)];
[set addCharactersInRange: NSMakeRange(0x1D175 , 1)];
[set addCharactersInRange: NSMakeRange(0x1D176 , 1)];
[set addCharactersInRange: NSMakeRange(0x1D177 , 1)];
[set addCharactersInRange: NSMakeRange(0x1D178 , 1)];
[set addCharactersInRange: NSMakeRange(0x1D179 , 1)];
[set addCharactersInRange: NSMakeRange(0x1D17A , 1)];
[set addCharactersInRange: NSMakeRange(0xE0001 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0020 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0021 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0022 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0023 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0024 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0025 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0026 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0027 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0028 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0029 , 1)];
[set addCharactersInRange: NSMakeRange(0xE002A , 1)];
[set addCharactersInRange: NSMakeRange(0xE002B , 1)];
[set addCharactersInRange: NSMakeRange(0xE002C , 1)];
[set addCharactersInRange: NSMakeRange(0xE002D , 1)];
[set addCharactersInRange: NSMakeRange(0xE002E , 1)];
[set addCharactersInRange: NSMakeRange(0xE002F , 1)];
[set addCharactersInRange: NSMakeRange(0xE0030 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0031 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0032 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0033 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0034 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0035 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0036 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0037 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0038 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0039 , 1)];
[set addCharactersInRange: NSMakeRange(0xE003A , 1)];
[set addCharactersInRange: NSMakeRange(0xE003B , 1)];
[set addCharactersInRange: NSMakeRange(0xE003C , 1)];
[set addCharactersInRange: NSMakeRange(0xE003D , 1)];
[set addCharactersInRange: NSMakeRange(0xE003E , 1)];
[set addCharactersInRange: NSMakeRange(0xE003F , 1)];
[set addCharactersInRange: NSMakeRange(0xE0040 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0041 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0042 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0043 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0044 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0045 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0046 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0047 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0048 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0049 , 1)];
[set addCharactersInRange: NSMakeRange(0xE004A , 1)];
[set addCharactersInRange: NSMakeRange(0xE004B , 1)];
[set addCharactersInRange: NSMakeRange(0xE004C , 1)];
[set addCharactersInRange: NSMakeRange(0xE004D , 1)];
[set addCharactersInRange: NSMakeRange(0xE004E , 1)];
[set addCharactersInRange: NSMakeRange(0xE004F , 1)];
[set addCharactersInRange: NSMakeRange(0xE0050 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0051 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0052 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0053 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0054 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0055 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0056 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0057 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0058 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0059 , 1)];
[set addCharactersInRange: NSMakeRange(0xE005A , 1)];
[set addCharactersInRange: NSMakeRange(0xE005B , 1)];
[set addCharactersInRange: NSMakeRange(0xE005C , 1)];
[set addCharactersInRange: NSMakeRange(0xE005D , 1)];
[set addCharactersInRange: NSMakeRange(0xE005E , 1)];
[set addCharactersInRange: NSMakeRange(0xE005F , 1)];
[set addCharactersInRange: NSMakeRange(0xE0060 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0061 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0062 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0063 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0064 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0065 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0066 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0067 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0068 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0069 , 1)];
[set addCharactersInRange: NSMakeRange(0xE006A , 1)];
[set addCharactersInRange: NSMakeRange(0xE006B , 1)];
[set addCharactersInRange: NSMakeRange(0xE006C , 1)];
[set addCharactersInRange: NSMakeRange(0xE006D , 1)];
[set addCharactersInRange: NSMakeRange(0xE006E , 1)];
[set addCharactersInRange: NSMakeRange(0xE006F , 1)];
[set addCharactersInRange: NSMakeRange(0xE0070 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0071 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0072 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0073 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0074 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0075 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0076 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0077 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0078 , 1)];
[set addCharactersInRange: NSMakeRange(0xE0079 , 1)];
[set addCharactersInRange: NSMakeRange(0xE007A , 1)];
[set addCharactersInRange: NSMakeRange(0xE007B , 1)];
[set addCharactersInRange: NSMakeRange(0xE007C , 1)];
[set addCharactersInRange: NSMakeRange(0xE007D , 1)];
[set addCharactersInRange: NSMakeRange(0xE007E , 1)];
[set addCharactersInRange: NSMakeRange(0xE007F , 1)];
[set addCharactersInRange: NSMakeRange(0x0000 , 1)];
[set addCharactersInRange: NSMakeRange(0x0001 , 1)];
[set addCharactersInRange: NSMakeRange(0x0002 , 1)];
[set addCharactersInRange: NSMakeRange(0x0003 , 1)];
[set addCharactersInRange: NSMakeRange(0x0004 , 1)];
[set addCharactersInRange: NSMakeRange(0x0005 , 1)];
[set addCharactersInRange: NSMakeRange(0x0006 , 1)];
[set addCharactersInRange: NSMakeRange(0x0007 , 1)];
[set addCharactersInRange: NSMakeRange(0x0008 , 1)];
[set addCharactersInRange: NSMakeRange(0x0009 , 1)];
[set addCharactersInRange: NSMakeRange(0x000A , 1)];
[set addCharactersInRange: NSMakeRange(0x000B , 1)];
[set addCharactersInRange: NSMakeRange(0x000C , 1)];
[set addCharactersInRange: NSMakeRange(0x000D , 1)];
[set addCharactersInRange: NSMakeRange(0x000E , 1)];
[set addCharactersInRange: NSMakeRange(0x000F , 1)];
[set addCharactersInRange: NSMakeRange(0x0010 , 1)];
[set addCharactersInRange: NSMakeRange(0x0011 , 1)];
[set addCharactersInRange: NSMakeRange(0x0012 , 1)];
[set addCharactersInRange: NSMakeRange(0x0013 , 1)];
[set addCharactersInRange: NSMakeRange(0x0014 , 1)];
[set addCharactersInRange: NSMakeRange(0x0015 , 1)];
[set addCharactersInRange: NSMakeRange(0x0016 , 1)];
[set addCharactersInRange: NSMakeRange(0x0017 , 1)];
[set addCharactersInRange: NSMakeRange(0x0018 , 1)];
[set addCharactersInRange: NSMakeRange(0x0019 , 1)];
[set addCharactersInRange: NSMakeRange(0x001A , 1)];
[set addCharactersInRange: NSMakeRange(0x001B , 1)];
[set addCharactersInRange: NSMakeRange(0x001C , 1)];
[set addCharactersInRange: NSMakeRange(0x001D , 1)];
[set addCharactersInRange: NSMakeRange(0x001E , 1)];
[set addCharactersInRange: NSMakeRange(0x001F , 1)];
[set addCharactersInRange: NSMakeRange(0x007F , 1)];
[set addCharactersInRange: NSMakeRange(0x0080 , 1)];
[set addCharactersInRange: NSMakeRange(0x0081 , 1)];
[set addCharactersInRange: NSMakeRange(0x0082 , 1)];
[set addCharactersInRange: NSMakeRange(0x0083 , 1)];
[set addCharactersInRange: NSMakeRange(0x0084 , 1)];
[set addCharactersInRange: NSMakeRange(0x0085 , 1)];
[set addCharactersInRange: NSMakeRange(0x0086 , 1)];
[set addCharactersInRange: NSMakeRange(0x0087 , 1)];
[set addCharactersInRange: NSMakeRange(0x0088 , 1)];
[set addCharactersInRange: NSMakeRange(0x0089 , 1)];
[set addCharactersInRange: NSMakeRange(0x008A , 1)];
[set addCharactersInRange: NSMakeRange(0x008B , 1)];
[set addCharactersInRange: NSMakeRange(0x008C , 1)];
[set addCharactersInRange: NSMakeRange(0x008D , 1)];
[set addCharactersInRange: NSMakeRange(0x008E , 1)];
[set addCharactersInRange: NSMakeRange(0x008F , 1)];
[set addCharactersInRange: NSMakeRange(0x0090 , 1)];
[set addCharactersInRange: NSMakeRange(0x0091 , 1)];
[set addCharactersInRange: NSMakeRange(0x0092 , 1)];
[set addCharactersInRange: NSMakeRange(0x0093 , 1)];
[set addCharactersInRange: NSMakeRange(0x0094 , 1)];
[set addCharactersInRange: NSMakeRange(0x0095 , 1)];
[set addCharactersInRange: NSMakeRange(0x0096 , 1)];
[set addCharactersInRange: NSMakeRange(0x0097 , 1)];
[set addCharactersInRange: NSMakeRange(0x0098 , 1)];
[set addCharactersInRange: NSMakeRange(0x0099 , 1)];
[set addCharactersInRange: NSMakeRange(0x009A , 1)];
[set addCharactersInRange: NSMakeRange(0x009B , 1)];
[set addCharactersInRange: NSMakeRange(0x009C , 1)];
[set addCharactersInRange: NSMakeRange(0x009D , 1)];
[set addCharactersInRange: NSMakeRange(0x009E , 1)];
[set addCharactersInRange: NSMakeRange(0x009F , 1)];

 [set removeCharactersInString:@"\r\n\t"];
}
return set;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]