Output single character in C

yes, %c will print a single char: printf(“%c”, ‘h’); also, putchar/putc will work too. From “man putchar”: #include <stdio.h> int fputc(int c, FILE *stream); int putc(int c, FILE *stream); int putchar(int c); * fputc() writes the character c, cast to an unsigned char, to stream. * putc() is equivalent to fputc() except that it may … Read more

How to get the number of characters in a string

You can try RuneCountInString from the utf8 package. returns the number of runes in p that, as illustrated in this script: the length of “World” might be 6 (when written in Chinese: “世界”), but the rune count of “世界” is 2: package main import “fmt” import “unicode/utf8” func main() { fmt.Println(“Hello, 世界”, len(“世界”), utf8.RuneCountInString(“世界”)) } … Read more

Get Description of Emoji Character

The Core Foundation function CFStringTransform() has transformations that determine the Unicode standard name for special characters. Example: let c : Character = “😄” let cfstr = NSMutableString(string: String(c)) as CFMutableString var range = CFRangeMake(0, CFStringGetLength(cfstr)) CFStringTransform(cfstr, &range, kCFStringTransformToUnicodeName, false) print(cfstr) Output: \N{SMILING FACE WITH OPEN MOUTH AND SMILING EYES} See http://nshipster.com/cfstringtransform/ for more information about … Read more