I am making a PDF file in Objective-C and all goes well. But when I add some curreny symbols in the PDF, it shows something totally different.
‚dž2,060,0 instead of €2,060,0
I have uses the following code to draw text in a PDF:
NSString *reducedString = @"€4,854,525";
CGContextShowTextAtPoint (currentContext,xPos, yPos, [textToDraw UTF8String], [reducedString length]);
Anyone knows how to draw the Euro symbol using this same code ? Is there anything I need to change in the text encoding?
[reducedString drawAtPoint:CGPointMake(xPos ,yPos) withFont:[UIFont systemFontOfSize:15];
Thanks in advance.
Try using the unicode of euro symbol
\u20AC
Right way to go is needs to use NSNumberFormatter.
NSInteger currency = 4345;
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
NSString *result = [numberFormatter stringFromNumber:[NSNumber numberWithInteger:currency]];
And result will be string with currency sign depending on the locale.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With