Country and Region Code Tools
Country code tooling: separates ISO 3166-1 alpha-2, alpha-3 and numeric codes, explains that ccTLDs, dialling codes and language codes are different systems, and covers the timezone root cause of off-by-one-day date bugs.
The question "the country code for China" has at least three answers, depending on which system you are looking in.
Approach Comparison
| System | Example (China) | Primary use |
|---|---|---|
| ISO 3166-1 alpha-2 | CN | Domains and most system identifiers |
| ISO 3166-1 alpha-3 | CHN | United Nations, some aviation and shipping |
| ISO 3166-1 numeric | 156 | Statistics and legacy systems |
| ccTLD | .cn | Country-code top-level domain |
| International dialling code | +86 | Telephone numbers |
| Language code | zh | ISO 639 language identifier |
| Complete locale | zh-CN | Language plus region |
| Unallocated country code | CN (root zone) | See the IANA root zone record |
Edge Cases
- ccTLDs do not map one-to-one with ISO codes: .uk is the UK domain while the ISO alpha-2 is GB.
- Dialling codes are not country codes either: +7 is shared by Russia and Kazakhstan.
- A language code (zh) combined with a region code (CN) forms the complete locale identifier zh-CN.
- Daylight saving transitions mean the offset from UTC shifts twice a year within a single zone.
Common Pitfalls
- Storing +86 in a column intended for ISO country codes, mixing two systems in one table.
- Matching the UK on ISO alpha-2 when the actual value is GB rather than UK, so every lookup fails.
- Formatting a UTC timestamp as if it were local time, landing on the wrong day.
- Adding or subtracting days on date strings, bypassing timezone and DST rules and producing wrong dates.
Related Tools
- Text StatisticsCount characters, words, lines, bytes and estimate reading time with sentence analysis to gauge content length and overall readability at a single glance.
- Text ReplacerFind and replace text with case-sensitive, whole-word and regex matching. Replace all at once with live preview, and review every hit before applying.
- Case ConverterConvert text between camelCase, snake_case, kebab-case, PascalCase and CONSTANT_CASE instantly. Switch naming styles for code, configs and identifiers.