Shelves / Internationalisation
IN·07
Internationalised Data and Infrastructure
The data and plumbing behind a global product: personal names without a first/last split, addresses that don't fit a US form, phone numbers in E.164 with libphonenumber, international email addresses and domain names with Punycode and homograph defences, usernames and confusables, database encodings and byte limits, CSV, HTTP and email headers, SMS encodings that cut a message from 160 to 70 characters, push payload limits, API conventions for locales, countries and currencies, and the regional rules on tax, payments and data residency; with a lab that normalises Indian phone formats, detects look-alike domains and hits a byte limit in PostgreSQL.
Start here: one phone number, six spellings
TiffinBox's sign-up form received the same mobile number typed six ways. The lab normalised each with Google's libphonenumber (Python port), default region India:
| Typed | Normalised (E.164) | Type |
|---|---|---|
98765 43210 |
+919876543210 | mobile, IN |
+91 98765-43210 |
+919876543210 | mobile, IN |
098765 43210 |
+919876543210 | mobile, IN |
0091 9876543210 |
+919876543210 | mobile, IN |
9876543210 |
+919876543210 | mobile, IN |
(040) 2345 6789 |
+914023456789 | fixed line, IN (Hyderabad) |
+1 (415) 555-0132 |
+14155550132 | US |
+971 50 123 4567 |
+971501234567 | mobile, AE |
12345 |
— | invalid |
Five spellings, one customer. A database that stored what was typed would have five accounts for them.
Two more results from the same lab:
tiffinbоx.in(with a Cyrillic о) andtіffinbox.in(with a Cyrillic і) look identical totiffinbox.inon screen; as DNS names they'rexn--tiffinbx-tbh.inandxn--tffinbox-thh.in, different domains anyone could register. A script check flagged both as mixed Latin and Cyrillic.- In PostgreSQL,
పెరుగు అన్నంis 12 characters and 34 bytes, the family emoji 5 characters and 18 bytes; avarchar(10)column rejected the six-letter Telugu dish name.
i18n reaches beyond the screen: identity data, network names, storage limits, messaging channels, and the laws of each market.
How deep to go
Volume 17 defines six mastery levels. For international data and infrastructure:
| Level | What you can do |
|---|---|
| L1 | Use UTF-8 everywhere; store phone numbers in E.164; use ISO codes |
| L2 | Build forms for names, addresses and phones that work worldwide |
| L3 | Explain IDNs, confusables, byte vs character limits, SMS and push encodings |
| L4 | Diagnose data-quality, delivery and spoofing problems in international data |
| L5 | Design identity, messaging and data-residency architecture for many markets |
| L6 | Run global identity, messaging or address infrastructure |
Personal names
Assumptions that break for real people: everyone has a first and last name; names are in Latin letters; names have a fixed length; the "last name" is the family name; names don't change; you can derive a greeting from the name.
Real examples: mononyms (one name only); family name first (Chinese, Japanese, Korean, Hungarian, often Vietnamese); South Indian names with an initial standing for a village or father's name (K. Ravi, where Ravi is the given name); Arabic names with patronymic chains (Muhammad bin Rashid); Spanish two-surname naming; names with apostrophes, hyphens and spaces; names in several scripts (a Telugu user's name in Telugu and in English).
Design:
- One full name field, free text, generous length (at least 100 graphemes), any script, normalised to NFC.
- A separate optional "What should we call you?" for greetings.
- If you need a Latin transliteration (for a courier label or a payment network), ask for it explicitly rather than generating it.
- Don't validate names with
[A-Za-z]or reject apostrophes; do strip control and bidi characters (chapter 06). - For sorting and search, store a search-normalised key (folded, transliterated) separately.
- Honorifics and formality (आप vs तुम, Herr/Frau, san) belong in the translation layer, not in name fields.
Addresses
Address formats differ in field order, which fields exist, and what's required:
| Country | Notable |
|---|---|
| India | 6-digit PIN code; house numbers often absent or informal; landmarks ("opposite Ratnadeep supermarket") are essential; locality and sub-locality matter more than street |
| UAE | no postcodes; many addresses are building + area + landmark; Dubai's Makani numbers and map pins help |
| US | 5- or 9-digit ZIP; state required; street-number-first |
| Japan, China | largest unit first (prefecture → city → block → building) |
| UK | alphanumeric postcodes that identify a few addresses |
Design:
- Use per-country address forms driven by data (Google's open address metadata, as used by
libaddressinput, or a provider's API), not one US-shaped form. - Keep a free-text delivery instructions/landmark field, and a map pin (latitude and longitude) for delivery businesses like TiffinBox; the pin is often more reliable than the text.
- Store the address as entered plus any normalised/geocoded form, and the country as an ISO 3166-1 code.
- Don't require a postcode or state where the country has none.
Phone numbers
- Store E.164 (
+919876543210); display in national or international format for the viewer (098765 43210in India,+91 98765 43210abroad). - Parse and validate with libphonenumber (Java/Kotlin original; ports for JavaScript, Python, Swift), using the user's region as the default for numbers typed without a country code. It knows trunk prefixes (
0), international prefixes (00,011), number lengths and types (mobile, fixed line, toll-free) for every country, and is updated as numbering plans change. - Type matters: an SMS OTP to a fixed line fails; the lab's
(040) 2345 6789is a Hyderabad landline. - Verify ownership with an OTP before trusting a number; numbers are reassigned when people churn.
- Don't assume one number per person or one person per number (shared family phones are common in India).
Email addresses and domain names
Internationalised domain names
Domain names can contain Unicode (टिफ़िनबॉक्स.भारत). DNS itself carries only ASCII, so each label is converted by IDNA (IDNA2008 plus Unicode's UTS #46 mapping rules) to Punycode, prefixed xn--. Browsers and email clients convert in both directions.
Homograph attacks exploit look-alike characters: Latin o and Cyrillic о, Latin i and Cyrillic і, Latin a and Cyrillic а, and many more. The lab's two fake domains looked like tiffinbox.in but were distinct registrations. Browsers defend by showing the Punycode form when a label mixes scripts in suspicious ways; you should:
- register obvious look-alikes of your own domain defensively;
- check links in your own product (chat, reviews, kitchen descriptions) with mixed-script and confusable detection: Unicode's UTS #39 defines a "skeleton" function that maps look-alikes to a common form, so
tіffinboxandtiffinboxhave the same skeleton; - display Punycode for suspicious URLs in user-generated content.
Email addresses
Since the EAI standards (RFC 6531, SMTPUTF8), the local part can be Unicode too (राम@उदाहरण.भारत). Support is uneven across mail servers, so accept such addresses, store them in NFC, and expect some deliveries to fail; don't validate emails with ASCII-only regexes. Compare domains case-insensitively after IDNA conversion; treat the local part as case-sensitive in principle, though most providers aren't.
Usernames and identifiers
For identifiers people choose (usernames, handles, kitchen URL slugs):
- normalise with NFKC and case folding (chapter 01), or follow the PRECIS framework (RFC 8264–8266);
- reject mixed scripts that aren't normal for a language (Latin + Cyrillic) or compare confusable skeletons to block look-alikes of existing names;
- reject invisible characters (zero-width spaces and joiners where not linguistically needed) and bidi controls.
Storage
Databases
- Encoding: create databases as UTF-8 (
ENCODING 'UTF8'in PostgreSQL;utf8mb4in MySQL, neverutf8/utf8mb3, which can't store emoji or some CJK characters). Set the client encoding to UTF-8 on every connection. - Limits in characters vs bytes: PostgreSQL's
varchar(n)counts characters (code points); MySQL'sVARCHAR(n)counts characters but row and index limits are in bytes (an index key prefix of 3,072 bytes holds 768utf8mb4characters); Oracle'sVARCHAR2(n)defaults to bytes unless declaredCHARsemantics. The lab'svarchar(10)rejected six Telugu letters because they were 12 code points; a byte limit would have been tighter still (34 bytes). - Size columns for the content, not for English: names and dish titles in Indic scripts need 3× the bytes and often more code points than their visible length suggests. Many teams simply use
textwith a check constraint on graphemes or a generous code-point limit. - Collation and search (chapter 02) and time types (chapter 03) are set per column.
Files, CSV and exports
- Write UTF-8. For CSVs opened in Excel, write a UTF-8 BOM, or Excel may decode with the system code page and show mojibake.
- Name exported files with ASCII-safe characters or test non-ASCII names on all target systems.
- PDFs (invoices, receipts) must embed fonts that cover the scripts used; a missing glyph prints as a blank box.
On the wire
HTTP
Content-Type: application/json; charset=utf-8(JSON is UTF-8 by standard, but say so for older clients) andtext/html; charset=utf-8.Accept-Languagefrom clients tells you their preferences; respond withContent-LanguageandVary: Accept-Languageif the response depends on it, so caches don't serve Hindi to an English user. Explicit user settings beat the header.- URLs: non-ASCII paths and query values are percent-encoded UTF-8 (
/menu/%E0%B0%AA…); domain labels use Punycode. Use libraries, not string concatenation. - Header values are effectively ASCII; encode non-ASCII (for example,
Content-Dispositionfile names usefilename*=UTF-8''…per RFC 6266/8187).
APIs
- Use standard codes: ISO 639/BCP 47 for languages, ISO 3166-1 alpha-2 for countries (
IN,AE,US), ISO 4217 for currencies, IANA zones for time zones, E.164 for phones, RFC 3339 for timestamps. - Return codes, not messages, for errors (chapter 05), and let clients pass a
localewhen the server must render text (emails, PDFs). - Accept and return text in NFC; document length limits with their unit.
Email, SMS and push
- Email: MIME handles UTF-8 bodies; non-ASCII subjects and names in headers use encoded words (RFC 2047). Templates are per-locale, with plain-text alternatives, and
lang/dirset in HTML. - SMS: the GSM 03.38 7-bit alphabet allows 160 characters per message (153 per part when split); one character outside it (any Indic letter, an emoji, even some accented letters) switches the message to UCS-2: 70 characters (67 per part). A Telugu OTP message of 100 characters costs two parts. Keep transactional SMS short; in India, templates must also be registered with operators under TRAI's DLT rules.
- Push notifications: APNs and FCM limit payloads to 4 KB (4,096 bytes), counted in UTF-8 bytes of the JSON; Indic text fits about a third as many characters as English. Send localisation keys and arguments (
loc-key,title_loc_key) so the device formats the text in its own language, or truncate by grapheme on the server.
Regional rules
Engineering has to meet local law and practice, which differs by market:
| Area | Examples |
|---|---|
| tax | India GST (rates by item, state-dependent IGST vs CGST/SGST, GSTIN on invoices); UAE VAT 5%; US sales tax by state, county and city |
| payment methods | UPI, RuPay and wallets in India; cards and Apple/Google Pay in the US; cash on delivery in many markets |
| invoices | legally required fields, numbering and language |
| data protection | India's Digital Personal Data Protection Act 2023 (with its rules phasing in); GDPR in the EU; US state laws; UAE federal data law: consent, purpose, retention and transfer rules |
| data residency | some sectors and countries require data to stay in-country; design regional storage (Volume 19) where needed |
| content and age rules | food labelling, alcohol, advertising, children's data |
Keep these as configuration per market (tax tables, payment providers, required fields, retention periods) rather than conditionals scattered through code, and involve legal and finance owners for each market.
Common traps
- First/last name fields and ASCII-only name validation.
- US-shaped address forms with required ZIP and state.
- Storing phone numbers as typed.
- ASCII-only email validation; no look-alike domain checks.
- MySQL
utf8, Oracle byte semantics and byte-sized index limits. - CSV exports without a BOM for Excel users.
- Responses varying by
Accept-LanguagewithoutVary. - Unicode SMS and push messages sized in characters instead of bytes.
- Market rules hard-coded in
if (country == "IN")branches.
Lab: phones, look-alike domains and byte limits
Setup. Python 3.13 on the lab machine with phonenumbers (the Python port of Google's libphonenumber), the standard library's IDNA codec, and unicodedata to find each character's script from its name; PostgreSQL 16.15 with a UTF-8 database and client encoding. The phone parser uses IN as the default region, as a sign-up form in India would. The domains are test strings; nothing was registered or looked up in DNS.
Results: phone numbers
| Input | E.164 | Valid | Type, region |
|---|---|---|---|
98765 43210 |
+919876543210 | yes | mobile, IN |
+91 98765-43210 |
+919876543210 | yes | mobile, IN |
098765 43210 |
+919876543210 | yes | mobile, IN |
0091 9876543210 |
+919876543210 | yes | mobile, IN |
(040) 2345 6789 |
+914023456789 | yes | fixed line, IN |
9876543210 |
+919876543210 | yes | mobile, IN |
+1 (415) 555-0132 |
+14155550132 | yes | fixed line or mobile, US |
+971 50 123 4567 |
+971501234567 | yes | mobile, AE |
12345 |
— | no |
Results: domains
| As displayed | DNS (ASCII) form | Scripts |
|---|---|---|
tiffinbox.in |
tiffinbox.in | Latin |
tiffinbоx.in (Cyrillic о) |
xn--tiffinbx-tbh.in | Cyrillic + Latin: mixed |
tіffinbox.in (Cyrillic і) |
xn--tffinbox-thh.in | Cyrillic + Latin: mixed |
Results: PostgreSQL
| Value | length() (characters) |
octet_length() (bytes) |
Insert into varchar(10) |
|---|---|---|---|
Lemon rice |
10 | 10 | ok |
పెరుగు అన్నం |
12 | 34 | rejected: value too long for type character varying(10) |
| 👨👩👧 | 5 | 18 |
server_encoding and client_encoding were both UTF8.
What it shows
- Normalise phone numbers on input: five ways of typing one mobile number became one E.164 value; the library also identified a landline and rejected a short number.
- Look-alike domains are distinct, registrable names; a simple mixed-script check catches the common attack, and confusable skeletons catch more.
- "Characters" in a database aren't what users see: six Telugu letters exceeded a 10-character column.
Try it yourself
- Parse
040-23456789with default regionIN, then withUS; explain the difference. - Implement UTS #39's skeleton with the
confusable_homoglyphsor ICUSpoofCheckerand testtiffinbox,tіffinbox,tiffinb0x. - Build a GSM-7 checker and compute how many SMS parts these need: "Your OTP is 482913", the same in Telugu, and the English with one emoji.
- Create a MySQL table with
VARCHAR(255)inutf8mb4and an index on it; insert Telugu text near the limit and read the error. - Write a CSV with Hindi text with and without a BOM and open both in a spreadsheet.
Revision sheet: internationalised data and infrastructure
Key ideas
- Names: one full-name field, any script, plus "what should we call you"; no ASCII validation; strip control characters.
- Addresses: per-country forms from data, landmarks and map pins, store as entered plus normalised, ISO country codes.
- Phones: parse with libphonenumber using a default region; store E.164; check type; verify with OTP.
- Domains: IDNA/Punycode; defend against homographs with mixed-script and confusable checks; accept Unicode email addresses.
- Identifiers: NFKC + case folding (or PRECIS), confusable skeletons, no invisible or bidi characters.
- Storage: UTF-8/utf8mb4; know whether limits count bytes or characters; size for Indic text; BOM for Excel CSV; embed fonts in PDFs.
- Wire: charset in Content-Type; Accept-Language with Vary; percent-encoded UTF-8 URLs; ISO codes in APIs; error codes not messages.
- SMS: 160 GSM-7 vs 70 UCS-2 characters; push payloads 4 KB in bytes; localise on device with keys.
- Market rules (tax, payments, invoices, privacy, residency) as per-market configuration.
Numbers to remember
- E.164: at most 15 digits. Indian PIN code: 6 digits.
- SMS: 160/153 (GSM-7), 70/67 (UCS-2).
- APNs/FCM payload: 4,096 bytes.
- MySQL InnoDB index key: 3,072 bytes = 768 utf8mb4 characters.
Glossary
- E.164: international phone-number format.
- IDNA / Punycode: conversion of Unicode domain labels to ASCII
xn--form. - Homograph attack: impersonation with look-alike characters.
- Confusable skeleton: UTS #39 form mapping look-alikes together.
- EAI / SMTPUTF8: internationalised email addresses.
- GSM-7 / UCS-2: SMS encodings.
- DLT: India's registration system for commercial SMS templates and senders.