简体   繁体   中英

NSString convertation from Windows-1251 to Windows-1252

I have NSString with "ÀÔÐÎÍÖÅÂ ÔÅÄ" text. I know that this text in Windows-1251 Encoding.

I want to convert it to Windows-1252 and show to user.

I try something like this, but its rise system exception:

NSString* newStr = [[NSString alloc] initWithData:theData encoding:NSWindowsCP1252StringEncoding];

now it works.

solution is:

var dt = new NSString(str);
var data = dt.Encode(NSStringEncoding.WindowsCP1252, true);
var result = new NSString(data, NSStringEncoding.WindowsCP1251);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM