The glyph character(❤︎)
you have used is consists of two unicode characters(\u2764\ufe0e),
so the two hearts displaying in (padded=❤︎❤︎)
are correct and represents four characters for padding length 4
.
Other simple characters like "k"
consists of one unicode character so it appears four times with padding length 4
.
This heart character(❤)
consists of one unicode character(\u2764)
, so if you use this, then four hearts will be displayed with padding length 4
.
You can also code like:
NSString *glyph = @"\u2764"; //for NSString *glyph = @"❤";
NSString *glyph = @"\u2764\ufe0e"; //for NSString *glyph = @"❤︎";
UPDATE after comments: Not sure about the easy way but I use following code for special characters to view its unicode :
NSData *data = [@"❤︎" dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"%@", str);