• 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: Converting ASCII to UTF-8?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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] initWithData:[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.


References: 
 >Converting ASCII to UTF-8? (From: "Huyler, Christopher M" <email@hidden>)

  • Prev by Date: Re: Converting ASCII to UTF-8?
  • Next by Date: Re: Converting ASCII to UTF-8?
  • Previous by thread: Re: Converting ASCII to UTF-8?
  • Next by thread: Re: Converting ASCII to UTF-8?
  • Index(es):
    • Date
    • Thread