• 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: NSScanner troubles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSScanner troubles


  • Subject: Re: NSScanner troubles
  • From: Ron Fleckner <email@hidden>
  • Date: Sat, 11 Dec 2010 19:03:23 +1100

On 11/12/2010, at 3:54 PM, Ken Thomases wrote:

> On Dec 10, 2010, at 9:38 PM, WT wrote:
>
>> thank you both for the very fast response.
>
> You're welcome.
>
>> Is that behavior of NSScanner documented anywhere? I read the docs but don't remember coming across it. I'm a bit stunned. What's the point of having a scanner if it ignores certain key aspects of the locale?
>
> It's not ignoring the locale.  There are just different ways of formatting numbers, and NSScanner just wasn't designed to understand some of them.  Group separators are more relevant to human-readable numbers than computer-readable ones.
>
> I would venture to say that NSScanner is an object-oriented analog to the scanf family of functions from the standard C library.  Those do not understand group separators, either.  It's pretty much the norm for number-scanning library routines.  It's also the norm for library routines to not include group separators when formatting numbers for output.  (e.g. -[NSNumber stringValue])
>
> Regards,
> Ken

Hi,

sorry if I'm way off the mark here, but wouldn't the best thing to use be NSScanner *scanner = [NSScanner localizedScannerWithString:[sender stringValue]];?  Then you don't have to worry about the specifics of number formatting in various locales.  Please let me know if I've missed the point.

Ron


_______________________________________________

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: NSScanner troubles
      • From: WT <email@hidden>
References: 
 >NSScanner troubles (From: WT <email@hidden>)
 >Re: NSScanner troubles (From: Greg Parker <email@hidden>)
 >Re: NSScanner troubles (From: WT <email@hidden>)
 >Re: NSScanner troubles (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: NSScanner troubles
  • Next by Date: Re: NSUnarchiver / Data.archive Extract all Keys
  • Previous by thread: Re: NSScanner troubles
  • Next by thread: Re: NSScanner troubles
  • Index(es):
    • Date
    • Thread