這是一個愚蠢的問題,但我只是沒有得到它的工作。我相信我需要轉換爲NSString並利用「stringWithUTF8String:」,但不明白如何在此代碼中實現它,所以我得到正確的輸出在NSLog中。我一直在環顧四周,但它仍然無法工作。 plist是正確的。UTF8愚蠢的問題
我的輸出是:
2010-11-07 21:43:00.419 plist_test[2984:207] Förbered och skriv
2010-11-07 21:43:00.425 plist_test[2984:207] KLART
2010-11-07 21:43:00.425 plist_test[2984:207] LÄS IN PLIST
2010-11-07 21:43:00.427 plist_test[2984:207] array2: (
ETT,
"TV\U00c5", ========Here is the problem, should be "TVÅ"
TRE,
FYRA
)
這裏是我使用的代碼。
- (void)viewDidLoad {
NSLog(@"Förbered och skriv");
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:@"ETT"];
[array addObject:@"TVÅ"];
[array addObject:@"TRE"];
[array addObject:@"FYRA"];
[array writeToFile:@"/Users/PeterK/Desktop/plisttest.plist" atomically: TRUE];
NSLog(@"KLART");
NSLog(@"LÄS IN PLIST");
NSMutableArray *array2 = [[NSMutableArray alloc] init];
array2 = [NSMutableArray arrayWithContentsOfFile:@"/Users/PeterK/Desktop/plisttest.plist"];
NSLog(@"array2: %@", array2); ====here is the output
[super viewDidLoad];
}
是那些正確序列化到文件上的字符串? – rano 2010-11-07 21:07:05
看起來還行我:http://www.fileformat.info/info/unicode/char/c5/index.htm – 2010-11-07 21:15:33