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
02400H&#9216;
12401H&#9217;
22402H&#9218;
32403H&#9219;
42404H&#9220;
52405H&#9221;
62406H&#9222;
72407H&#9223;
82408H&#9224;
92409H&#9225;
10240AH&#9226;
11240BH&#9227;
12240CH&#9228;
13240DH&#9229;
14240EH&#9230;
15240FH&#9231;
162410H&#9232;
172411H&#9233;
182412H&#9234;
192413H&#9235;
202414H&#9236;
212415H&#9237;
222416H&#9238;
232417H&#9239;
242418H&#9240;
252419H&#9241;
26241AH&#9242;
27241BH&#9243;
28241CH&#9244;
29241DH&#9245;
30241EH&#9246;
31241FH&#9247;
322420H&#9248;
1272421H&#9249;
322423H&#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