//功能:获取字符串的UTF8编码
//参数:好友名
//参数:返回账户名的字符串
//备注:11/3 lilin 添加
-(NSString *)EncodeUTF8Str:(NSString *)encodeStr
{
CFStringRef nonAlphaNumValidChars = CFSTR("![ DISCUZ_CODE_1 ]’()*+,-./:;=?@_~");
NSString *preprocessedString = (NSString*)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, (CFStringRef)encodeStr, CFSTR(""), kCFStringEncodingUTF8);
NSString *newStr = [(NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,(CFStringRef)preprocessedString,NULL,nonAlphaNumValidChars,kCFStringEncodingUTF8) autorelease];
[preprocessedString release];
return newStr;
}
//功能:获取字符串的GB2312编码
//参数:好友名
//参数:返回账户名的字符串
//备注:11/3 lilin 添加
-(NSString *)EncodeGB2312Str:(NSString *)encodeStr
{
CFStringRef nonAlphaNumValidChars = CFSTR("![ DISCUZ_CODE_1 ]’()*+,-./:;=?@_~");
NSString *preprocessedString = (NSString*)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, (CFStringRef)encodeStr, CFSTR(""), kCFStringEncodingGB_18030_2000);
NSString *newStr = [(NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,(CFStringRef)preprocessedString,NULL,nonAlphaNumValidChars,kCFStringEncodingGB_18030_2000) autorelease];
[preprocessedString release];
return newStr;
}