rot47 中文 转 ASCII

来源:互联网 发布:ip与mac地址扫描工具 编辑:程序博客网 时间:2024/05/18 05:30
#pragma mark - rot47 encode- (NSString *)rot47 {    const char *_string = [self cStringUsingEncoding:NSNonLossyASCIIStringEncoding];    NSUInteger stringLength = strlen(_string);    char newString[stringLength + 1];    int x;    for(x = 0; x<stringLength; x++) {        unsigned int aCharacter = _string[x];        if( 0x20 < aCharacter && aCharacter < 0x7F ) // from ! to ~            newString[x] = (((aCharacter - 0x21) + 0x2F) % 0x5E) + 0x21;        else  // Not an r47 character            newString[x] = aCharacter;    }    newString[x] = '\0';    NSString *rotString = [NSString stringWithCString:newString encoding:NSNonLossyASCIIStringEncoding];    MJExtensionLog(@"%@ = %@",self,rotString);    return rotString;}

也可以中文先urlencode 转字符,然后再ASII rot

原创粉丝点击