Text Encoding ComparisonASCII vs UTF-8 vs UTF-16 vs UTF-32ASCII(7-bit, 1 byte)Letter "A"7654321001000001Hex: 41• English only• 128 characters• Fixed length• Compact• Not multilingualUTF-8(1-4 bytes)Letter "A"7654321001000001Hex: 41Euro "€"765432101110001076543210100000107654321010101100Hex: E2 82 AC• ASCII compatible• Variable length• Web standardUTF-16(2-4 bytes)Letter "A"76543210000000007654321001000001Hex: 00 41Japanese "あ"76543210001100107654321001100001Hex: 30 42• Windows default• Variable length• Asian: 2 bytesUTF-32(Fixed 4 bytes)Letter "A"7654321000000000765432100000000076543210000000007654321001000001Hex: 00 00 00 41• Fixed length• Performance optimized• Easy string operations• Space inefficient• All chars: 4 bytesSize vs Performance TradeoffUTF-8: Size Optimized • UTF-16: Balance • UTF-32: Performance Optimized
Mastodon