Sometimes we need to display non printable characters (ASCII code < 32 or ASCII code > 127) for debug reason. Of course we can escape the characters to hexical code, such as '\x0a\x0d', but sometimes using “Control Pictures” code page in Unicode might be a better idea, because it requires less screen space.

ASCIIPictureHexHTML Entity
0␀2400H&#9216;
1␁2401H&#9217;
2␂2402H&#9218;
3␃2403H&#9219;
4␄2404H&#9220;
5␅2405H&#9221;
6␆2406H&#9222;
7␇2407H&#9223;
8␈2408H&#9224;
9␉2409H&#9225;
10␊240AH&#9226;
11␋240BH&#9227;
12␌240CH&#9228;
13␍240DH&#9229;
14␎240EH&#9230;
15␏240FH&#9231;
16␐2410H&#9232;
17␑2411H&#9233;
18␒2412H&#9234;
19␓2413H&#9235;
20␔2414H&#9236;
21␕2415H&#9237;
22␖2416H&#9238;
23␗2417H&#9239;
24␘2418H&#9240;
25␙2419H&#9241;
26␚241AH&#9242;
27␛241BH&#9243;
28␜241CH&#9244;
29␝241DH&#9245;
30␞241EH&#9246;
31␟241FH&#9247;
32␠2420H&#9248;
127␡2421H&#9249;
32␣2423H&#9251;

And here is a simple method to convert the characters in a string.

@implementation ControlPictures

+ (unichar)controlPictureByCharacter:(unichar)ch {
    if (ch < 33) {
        return (unichar)(ch + 0x2400);
    } else if (ch == 127) {
        return (unichar)0x2421;
    } else {
        return ch;
    }
}

+ (NSString *)stringByReplacingControlCharacters:(NSString *)str {
    NSMutableString *result = [@"" mutableCopy];
    for (NSInteger idx = 0; idx < str.length; idx++) {
        [result appendFormat:@"%C", [ControlPictures controlPictureByCharacter:[str characterAtIndex:idx]]];
    }
    return result;
}

@end