Created
May 20, 2011 13:22
-
-
Save 0xced/982878 to your computer and use it in GitHub Desktop.
Swiss Franc currency symbol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| // Swiss law on money (german): http://www.admin.ch/ch/d/sr/9/941.101.de.pdf | |
| // Swiss law on money (french): http://www.admin.ch/ch/f/rs/9/941.101.fr.pdf | |
| int main(int argc, const char *argv[]) | |
| { | |
| NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
| NSArray *localeIdentifiers = [NSArray arrayWithObjects:@"de_CH", @"fr_CH", @"it_CH", @"rm_CH", nil]; | |
| NSArray *officialCurrencySymbols = [NSArray arrayWithObjects:@"Fr.", @"fr.", @"fr.", @"fr.", nil]; | |
| NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; | |
| for (NSUInteger i = 0; i < [localeIdentifiers count]; i++) | |
| { | |
| NSString *localeIdentifier = [localeIdentifiers objectAtIndex:i]; | |
| NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier] autorelease]; | |
| [numberFormatter setLocale:locale]; | |
| NSString *currencySymbol = [numberFormatter currencySymbol]; | |
| NSString *officialCurrencySymbol = [officialCurrencySymbols objectAtIndex:i]; | |
| BOOL isCorrect = [currencySymbol isEqualToString:officialCurrencySymbol]; | |
| NSString *comment = isCorrect ? @"OK" : [NSString stringWithFormat:@"should be \"%@\"", officialCurrencySymbol]; | |
| printf("%s: \"%s\" (%s)\n", [localeIdentifier UTF8String], [currencySymbol UTF8String], [comment UTF8String]); | |
| } | |
| [numberFormatter setLocale:nil]; | |
| NSString *internationalCurrencySymbol = [numberFormatter internationalCurrencySymbol]; | |
| BOOL isCorrect = [internationalCurrencySymbol isEqualToString:@"CHF"]; | |
| NSString *comment = isCorrect ? @"OK" : @"should be \"CHF\""; | |
| printf("international: \"%s\" (%s)\n", [internationalCurrencySymbol UTF8String], [comment UTF8String]); | |
| [pool drain]; | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| all: chf | |
| chf: chf.m | |
| gcc chf.m -o chf -framework Foundation -std=c99 | |
| clean: | |
| rm -f chf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Region: US
Region: Switzerland (French)
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
Mac OS X 10.7, Build 11A511, Xcode 4.2 Developer Preview 3 (Lion 4D75)