Fundamentals · Medium · Free
What is the difference between ASCII and Unicode? Why does encoding matter?
FresherFundamentalsProgramming Fundamentals
ASCII vs Unicode
ASCII maps 128 (or 256 extended) characters to byte values—fine for English. Unicode is a universal character set; UTF-8 encodes Unicode code points as variable-length bytes (ASCII-compatible for English).
| Term | What it is | Interview note |
|---|---|---|
| Code point | Number for a character (e.g. U+20B9 ₹) | Stored in String, not one byte |
| UTF-8 | Encoding of Unicode to bytes | Default on web and JVM |
| Mojibake | Wrong decoding shows | Always declare UTF-8 in APIs |
java
String s = "café"; // JVM strings are UTF-16 internally
byte[] utf8 = s.getBytes(StandardCharsets.UTF_8);Interview tip: Tie to emoji/Indian languages—why
charAt is not always one user-visible character (use code points).