• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What is this invisible character?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is this invisible character?


  • Subject: Re: What is this invisible character?
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 18 Mar 2008 22:47:57 -0700


On 18 Mar '08, at 9:53 PM, J. Todd Slack wrote:

So how do I write out a text file in UTF16-BE encoding? Maybe this would
solve my problem.

You *are* writing it out in that encoding; that's the problem. It's not the default text encoding, so apps won't interpret the text correctly. You generally want to save text files in UTF-8.


if ([predefinedSessionDocumentsFileContents writeToFile:
pathToUsersImpressionDocumentsSessionFile atomically: YES]) {}
else { NSLog (@"Failure writing Documents Session File On Startup");
}

You want -writeToFile:atomically:encoding: instead. Pass NSUTF8StringEncoding as the last parameter.


(I'm kind of surprised that the method you're calling generates UTF-16. Maybe that's part of the reason it's marked as deprecated!)

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: What is this invisible character?
      • From: "J. Todd Slack" <email@hidden>
References: 
 >Re: What is this invisible character? (From: "J. Todd Slack" <email@hidden>)

  • Prev by Date: Re: Adding spaces to an NSString
  • Next by Date: Re: Setting Web Proxy programmatically
  • Previous by thread: Re: What is this invisible character?
  • Next by thread: Re: What is this invisible character?
  • Index(es):
    • Date
    • Thread