• 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: Odd display of percent character
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Odd display of percent character


  • Subject: Re: Odd display of percent character
  • From: Ken Thomases <email@hidden>
  • Date: Mon, 13 Feb 2012 13:01:43 -0600

On Feb 13, 2012, at 11:04 AM, Chris Paveglio wrote:

> I'm having an issue with the percent character being displayed as random numbers in an NSAlertPanel (modal). My app has an ivar, "fullString", including the usual property/synthesize getters and setters, there is nothing special about it. fullString is bound to an NSTextField where a user might type "10% off all shoes", or put some text that contains dollar signs or percent signs. Later another method will validate if it's a web address or plain text and display an alert if it's not a web address. At this point I use the usual -stringWithFormat and put the "fullString" text in with some other descriptive text. But if fullString contains a percent character, then the NSAlert displays something like "10254458745ff all shoes". Why is the percent character being turned into some numbers, and it also seems to lop off the space and letter o as well? Using ampersand, dollar sign, and number symbol all display properly.
> FWIW, I am using objective-C++, because my QR code library project is C++ and I need to compile it all the same (first time I've had to do anything like this). Would that be somehow mangling my string in the NSAlert display? If I do NSLog on the string displayed in the NSAlert it also logs properly. So why the discrepancy in the Alert?

Show your code.  It sounds like you are using fullString as a format string, not as an argument being formatted into a format string.  In the format string, percent signs introduce format specifiers (e.g. %d, %@, etc.).  That's what's causing the percent signs in your string to produce odd results.

Regards,
Ken


_______________________________________________

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


References: 
 >Odd display of percent character (From: Chris Paveglio <email@hidden>)

  • Prev by Date: Re: Odd display of percent character
  • Next by Date: Re: Odd display of percent character
  • Previous by thread: Re: Odd display of percent character
  • Next by thread: Re: Odd display of percent character
  • Index(es):
    • Date
    • Thread