1. Hexadecimal Integer Literals (0x...)
Across virtually all modern languages (C, C++, Rust, Go, Python, JavaScript, Java, C#), hexadecimal integers are written using the 0x or 0X prefix.
uint32_t mask = 0xFF00AA;
let color: u32 = 0xDEAD_BEEF;
buffer_size = 0x1000 # 4096 bytes
const maxByte = 0xFF; // 255
2. String Byte Escapes (\x) vs. Unicode (\u)
When encoding binary buffers or unprintable control characters inside text strings:
- Byte Escape (
\xHH): Encodes an 8-bit byte. E.g.,"\x41\x42"evaluates to"AB". - 16-Bit Unicode (
\uHHHH): Encodes a Basic Multilingual Plane code point. E.g.,"\u00E9"produces"é". - Variable Unicode (
\u{H...}): Supported in modern JS and Rust to write any Unicode character up to U+10FFFF without surrogate pairs. E.g.,"\u{1F600}"produces"😀".
3. Web Standards: URLs, HTML & CSS
Encodes non-ASCII or reserved characters: %20 (space), %2F (slash), %3F (question mark).
Format: &#xHH;. For example, © renders the copyright symbol (©).
Syntax: #RRGGBB or #RRGGBBAA. For example, #0284C7 defines sky blue.