The oldest trick in the ASCII book
The ASCII table has a peculiarity where uppercase letters have an ASCII code 0x20 less than their lowercase counterparts. This fact can be used in certain situations to convert ASCII text to uppercase using bitwise AND operation, which is particularly useful when dealing with protocols that use USASCII characters for their commands such as SMTP, POP3, DNS names and HTTP headers. In C programming language, this trick can be employed to make very fast case-insensitive comparisons in situations where high performance is required, like handling millions of DNS packets per second.
Company
Cloudflare
Date published
April 12, 2015
Author(s)
John Graham-Cumming
Word count
329
Hacker News points
None found.
Language
English