美文网首页
查看 NSCharacterSet 字符集

查看 NSCharacterSet 字符集

作者: 流星企盼 | 来源:发表于2019-01-18 11:31 被阅读8次

    查看NSCharacterSet的字符集

    NSCharacterSet *charset = NSCharacterSet.URLQueryAllowedCharacterSet;
    NSMutableArray *array = [NSMutableArray array];
    for (int plane = 0; plane <= 16; plane++) {
        if ([charset hasMemberInPlane:plane]) {
            UTF32Char c;
            for (c = plane << 16; c < (plane+1) << 16; c++) {
                if ([charset longCharacterIsMember:c]) {
                    UTF32Char c1 = OSSwapHostToLittleInt32(c); // To make it byte-order safe
                    NSString *s = [[NSString alloc] initWithBytes:&c1 length:4 encoding:NSUTF32LittleEndianStringEncoding];
                    [array addObject:s];
                }
            }
        }
    }
    NSLog(@"%@", [array componentsJoinedByString:@""]);
    

    NSCharacterSet (NSURLUtilities) 的字符集内容

    URLUserAllowedCharacterSet  
    !$&'()*+,-.0123456789;=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~
    
    URLPasswordAllowedCharacterSet
    !$&'()*+,-.0123456789;=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~
    
    URLHostAllowedCharacterSet
    !$&'()*+,-.0123456789:;=ABCDEFGHIJKLMNOPQRSTUVWXYZ[]_abcdefghijklmnopqrstuvwxyz~
    
    URLPathAllowedCharacterSet
    !$&'()*+,-./0123456789:=@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~
    
    URLQueryAllowedCharacterSet
    !$&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~
    
    URLFragmentAllowedCharacterSet
    !$&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~
    

    Note: 上述的字符集中和网上其他博客提供的出入相当大,实际使用中被网上几乎所有的博客给坑了,特此记录下

    相关文章

      网友评论

          本文标题:查看 NSCharacterSet 字符集

          本文链接:https://www.haomeiwen.com/subject/weagdqtx.html