Skip navigation.
 
mlRe: Saving UTF-8 as File
FROM : John Stiles
DATE : Tue Apr 19 20:44:34 2005

On Apr 19, 2005, at 11:26 AM, Jim Hamilton wrote:

>> Can someone point me in the right direction to be able to save the
>> HTML string as a UTF-8 encoded file?

>
> 1)  Do you start the file with a BOM?  (Check unicode.org to be sure,
> but I think it's 0xEF 0xBB 0xBF.)
>
> 2)  Does your HTML have an encoding tag?  ("charset=utf-8" in a meta
> tag)


I don't know if #1 is relevant--HTML doesn't require a BOM, nor does it
cause any problems if one exists.
#2, OTOH, is critical. If you aren't specifying UTF8 encoding, you will
not get the right results.
I agree with some other posters in the thread--use [myString
UTF8String] and output that. It seems as if the NSString writeToFile
method does not give you enough control over encodings.

Related mailsAuthorDate
mlSaving UTF-8 as File August Trometer Apr 19, 19:53
mlRe: Saving UTF-8 as File Ondra Cada Apr 19, 20:23
mlRe: Saving UTF-8 as File Jim Hamilton Apr 19, 20:26
mlRe: Saving UTF-8 as File Douglas Davidson Apr 19, 20:26
mlRe: Saving UTF-8 as File Shawn Erickson Apr 19, 20:30
mlRe: Saving UTF-8 as File Tim Gogolin Apr 19, 20:31
mlRe: Saving UTF-8 as File Shawn Erickson Apr 19, 20:35
mlRe: Saving UTF-8 as File Sherm Pendley Apr 19, 20:39
mlRe: Saving UTF-8 as File John Stiles Apr 19, 20:44
mlRe: Saving UTF-8 as File August Trometer Apr 19, 20:57
mlRe: Saving UTF-8 as File Ondra Cada Apr 19, 21:18