Created
May 28, 2011 12:46
-
-
Save cxa/996837 to your computer and use it in GitHub Desktop.
Convert Arabic number to Chinese
This file contains 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
#define CHAR_MAX 32 | |
NSString* toChineseNumer(NSUInteger num){ | |
static NSString *cnums = @"〇一二三四五六七八九"; | |
unichar ch[32]; | |
int i = 0; | |
do ch[i++] = [cnums characterAtIndex:num%10]; | |
while ((num /= 10) > 0); | |
unichar *reverse = calloc(sizeof(unichar), i); | |
for (int j=0; j<i; j++) reverse[j] = ch[i-j-1]; | |
NSString *ret = [[NSString alloc] initWithCharacters:reverse length:i]; | |
free(reverse); | |
return [ret autorelease]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment