Changeset 839

Show
Ignore:
Timestamp:
08/09/08 21:57:20 (3 months ago)
Author:
kaz
Message:

*Fixed #153

  • Re-implement encodeAsURICompoent
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/TwitterFon/Classes/OtherSources/StringUtil.m

    r770 r839  
    1212- (NSString*)encodeAsURIComponent 
    1313{ 
    14     NSString* s = (NSString*)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)self, NULL, NULL, kCFStringEncodingUTF8); 
    15     return [s autorelease]; 
     14        const char* p = [self UTF8String]; 
     15        NSMutableString* result = [NSMutableString string]; 
     16         
     17        for (;*p ;p++) { 
     18                unsigned char c = *p; 
     19                if ('0' <= c && c <= '9' || 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '-' || c == '_') { 
     20                        [result appendFormat:@"%c", c]; 
     21                } else { 
     22                        [result appendFormat:@"%%%02X", c]; 
     23                } 
     24        } 
     25        return result; 
    1626} 
     27 
    1728 
    1829- (NSString*)escapeHTML