Re: Saving UTF-8 as File
Re: Saving UTF-8 as File
- Subject: Re: Saving UTF-8 as File
- From: Shawn Erickson <email@hidden>
- Date: Tue, 19 Apr 2005 11:35:23 -0700
On Apr 19, 2005, at 11:30 AM, Shawn Erickson wrote:
On Apr 19, 2005, at 10:53 AM, August Trometer wrote:
I have a situation where I need to create some HTML on the fly and
save it to a file, then turn around and have WebKit read the file
using a file:// URL. (Why? NDA until the 29th.)
If I give WebKit the straight string, it handles any UTF-8 characters
just fine.
However, when I save to a file (using NSString
writeToFile:atomically), it doesn't save as UTF-8 and when the file
is read I get all kinds of bogus characters.
Can someone point me in the right direction to be able to save the
HTML string as a UTF-8 encoded file?
Consider using dataUsingEncoding: or
dataUsingEncoding:allowLossyConversion:
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Classes/NSString.html#//apple_ref/doc/uid/20000154/
dataUsingEncoding_>
I also meant to point out that writeToFile:atomically: uses the default
encoding which can be found using +defaultCStringEncoding (this is
pointed out in the API docs for NSString) or UTF16
(NSUnicodeStringEncoding) depending on string contents.
Not sure how you are reading things back in...
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden