Re: string encoding
Re: string encoding
- Subject: Re: string encoding
- From: Bill Cheeseman <email@hidden>
- Date: Fri, 06 Jun 2003 06:18:21 -0400
on 03-06-05 9:12 PM, Lloyd Dupont at email@hidden wrote:
>
I'm about to write NSString(s) into a file.
>
I wondered about the most proper way ...
>
>
>
Anyway, I choose to use NSFileHandle, and use multiple call to
>
writeData:
>
now I have an other problem.
>
I wonder which encoding choose to write my string.
>
I see the NSString class gaves me the fastestEncoding, smallestEncoding
>
and the defaultCStringEncoding which look interesting.
>
I wonder if there is a defaultMacEncoding ?
>
what would you advise me ?
>
in case of doubt I will choose NSMacOSRomanStringEncoding
Look at the documentation for NSString's +availableStringEncodings for a
list of and reference to all available Cocoa and Core Foundation encodings.
How you save a string involves deciding what it might be used for. Some
encodings will lose information so that it can't be regained if the user
retrieves the string and tries to convert it to some other encoding.
You also have to worry about portability and localization issues. For
example, defaultCStringEncoding might not look right on another computer
that has some other language as its first choice in System Preferences,
because the default C string encoding differs among languages.
And, if you're working with file system paths obtained as C strings from
system routines, don't overlook the fileSystemRepresentation methods in
NSFileManager and NSString.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
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.