• 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: Why would -[NSString dataUsingEncoding:allowLossyConversion:] throw exception?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why would -[NSString dataUsingEncoding:allowLossyConversion:] throw exception?


  • Subject: Re: Why would -[NSString dataUsingEncoding:allowLossyConversion:] throw exception?
  • From: "Ken Ferry" <email@hidden>
  • Date: Tue, 9 Jan 2007 18:43:29 -0800

I was able to reproduce this in a test app, and I filed a bug for it.
I had to write your string out to MacOS Roman data, make a string from that,
and then write _that_ out to ASCII to produce the exception.

-Ken

On 1/8/07, Dan Wood <email@hidden> wrote:


I'm trying to downsample a string to pure ASCII using the -[NSString
dataUsingEncoding:allowLossyConversion:] like this:

        NSData *asciiData = [theString
dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

However, in some circumstances I get an exception thrown:

*** -[NSCFString dataUsingEncoding:allowLossyConversion:]: didn't
convert all characters


For instance, when I pass in the string "Det er gratis…" (the last character is U+2026) it happens.

I'm not finding any documentation that it might throw an exception.
Isn't the point of passing in YES so that you can still get something
back even if not all characters are converted?


I tried a little test project with just this operation, and I didn't get the exception. Any idea why it might function variably?


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >Why would -[NSString dataUsingEncoding:allowLossyConversion:] throw exception? (From: Dan Wood <email@hidden>)

  • Prev by Date: NSStatusItem not highlighted when using NSWindow instead of NSMenu
  • Next by Date: any api for the iphone/compiler?
  • Previous by thread: Re: Why would -[NSString dataUsingEncoding:allowLossyConversion:] throw exception?
  • Next by thread: Setting selections in NSArrayController from view
  • Index(es):
    • Date
    • Thread