Re: Converting ASCII to UTF-8?
Re: Converting ASCII to UTF-8?
- Subject: Re: Converting ASCII to UTF-8?
- From: Andreas Mayer <email@hidden>
- Date: Tue, 30 Mar 2004 02:43:45 +0200
Am 29.03.2004 um 23:57 schrieb Huyler, Christopher M:
If I read an ASCII string in from a file and store it in an NSString,
Um... +stringWithContentsOfFile:?
how could I convert it to UTF-8 so it will display properly?
If it's ASCII there's nothing to convert.
If it's *not* ASCII you'll have to know the original encoding it is in.
In that case use
NSString *string = [[NSString alloc] initWith
Data:[NSData
dataWithContentsOfFile:path] encoding:stringEncoding];
where stringEncoding is an NSStringEncoding. See list at
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/TypesAndConstants/FoundationTypes.html
section String Encodings.
Also this is kind of a FAQ. Search the list archives for more
information.
Andreas
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.