zoukankan      html  css  js  c++  java
  • IOS asc码替换

     

    -(void)click:(UIButton *)btn

    {

        NSString *testStr = @">全等";

        

        NSStringEncoding encoding2 = NSUTF8StringEncoding;

        

        testStr = [testStr stringByReplacingOccurrencesOfString:@" " withString:@""];

        testStr = [testStr stringByReplacingOccurrencesOfString:@"x15" withString:@""];

        testStr = [testStr stringByTrimmingCharactersInSet:[NSCharacterSet controlCharacterSet]];

        testStr = [testStr stringByTrimmingCharactersInSet:[NSCharacterSet controlCharacterSet]];

        

        

        testStr = [testStr stringByTrimmingCharactersInSet:[NSCharacterSet illegalCharacterSet]];

        testStr = [testStr stringByTrimmingCharactersInSet:[NSCharacterSet symbolCharacterSet]];

        testStr = [testStr stringByTrimmingCharactersInSet:[NSCharacterSet nonBaseCharacterSet]];

        testStr = [testStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

        

        NSMutableString *newStr = [[NSMutableString alloc]initWithCapacity:1];

        

        for (int i = 0; i < [testStr length]; i++) {

            unichar c = [testStr characterAtIndex:i];

            

            

            if(c>=0 && c<=31)

            {

                continue;

            }

            

            [newStr appendString:[NSString stringWithFormat:@"%@", [testStr substringWithRange:NSMakeRange(i, 1)]]];

            

            int bytesLeng = [[testStr substringWithRange:NSMakeRange(i, 1)] lengthOfBytesUsingEncoding:encoding2];

            

            NSLog(@"testStr[%d]=%@ = %d,%d", i, [testStr substringWithRange:NSMakeRange(i, 1)], c, bytesLeng);

        }

        NSLog(@"%@=%d, %@=%d", testStr, [testStr length], newStr, [newStr length]);

        

        

        

    }

  • 相关阅读:
    codeforces 269B Greenhouse Effect
    codeforces 5C Longest Regular Bracket Sequence
    codeforces 225C Barcode
    codeforces 279C Ladder
    CodeForces 479E Riding in a Lift
    CodeForces 351A Jeff and Rounding
    POJ-1579-201308122106.txt
    表达式求值-201308081712.txt
    Encoding-201308072147.txt
    A + B Problem II201308072001.txt
  • 原文地址:https://www.cnblogs.com/xiangjune/p/5600601.html
Copyright © 2011-2022 走看看