iOS 适用于大写英文的全角转半角

来源:互联网 发布:js绑定事件的方法 编辑:程序博客网 时间:2024/06/06 05:35
-(NSString *)changeToSBCCode:(NSString *)aSBCCodeString{    //65248//    aSBCCodeString = @"ABCDEAaa";//65313-65338 65,97 65345    NSLog(@"转换前%@",aSBCCodeString);    NSMutableString *tResult = [NSMutableString stringWithUTF8String:""];    for (NSInteger tIndex = 0; tIndex< aSBCCodeString.length; tIndex++) {        unichar tChar = [aSBCCodeString characterAtIndex:tIndex];        if (tChar >65248) {            tChar -=65248;        }        [tResult appendString:[NSString stringWithFormat:@"%c",tChar]];    }    NSLog(@"转换后%@",tResult);    return tResult;}
0 0