NSString:localizedStringWithFormat: returns wrong string when formatter contains a "+"
| Originator: | vp | ||
| Number: | rdar://12607135 | Date Originated: | 31-Oct-2012 12:21 PM |
| Status: | Open | Resolved: | |
| Product: | iPhone SDK | Product Version: | 6.0 |
| Classification: | Reproducible: | YES |
Summary:
NSString:localizedStringWithFormat: returns wrong string when formatter contains a "+".
Steps to Reproduce:
Print out a number with stringWithFormat and localizedStringWithFormat.
Sample code:
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
float value = -1.0;
NSString *s1 = [NSString stringWithFormat:@"%+.2f", value];
NSString *s2 = [NSString localizedStringWithFormat:@"%+.2f", value];
NSLog(@"stringWithFormat: %@", s1);
NSLog(@"localizedStringWithFormat: %@", s2);
[p release];
}
Expected Results:
Both log outputs should _not_ show a "+" in front of the number since it is negative (as specified in the "String Programming Guide" and "IEEE 1003.1")
Actual Results:
Output of the above code is:
2012-10-31 12:16:51.621 Untitled[65470:707] stringWithFormat: -1.00
2012-10-31 12:16:51.623 Untitled[65470:707] localizedStringWithFormat: -+1.00
(there's one extra "+" when using localizedStringWithFormat).
Regression:
n/a
Notes:
n/a
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!