Unicode's bold alphabet has holes in it, and every text generator falls in
If you have ever built a "fancy text" generator — the things people paste into Instagram bios and Discord names — you have written this function: // Looks right. Is wrong. const toBold = text => text . replace ( / [ A-Za-z ] /g , ch => { const c = ch . charCodeAt ( 0 ); return c <= 90 ? String . fromCodePoint ( 0x1D400 + ( c - 65 )) // A-Z : String . fromCodePoint ( 0x1D41A + ( c - 97 )); // a-z…
Unicode's bold alphabet has gaps, and every text generator falls short. When building fancy text generators for Instagram bios and Discord names, developers write a function that converts regular letters to their bold counterparts. The function works for basic text like "Hello World" and converts it to 𝐇𝐞𝐥𝐥𝐨 𝐖𝐨𝐫𝐥𝐝. However, it fails when someone types their name in cursive, resulting in blank squares ☐.
The issue lies with the Mathematical Alphanumeric Symbols block, which contains about a dozen styled Latin alphabets, including bold, italic, bold italic, script, bold script, fraktur, double-struck, sans-serif, monospace, and digit sets. The block appears clean, with 26-letter runs, but it is not. Some letters already existed in the Letterlike Symbols block, so Unicode left those slots permanent.
Five alphabets have gaps, including script B, E, F, H, I, L, M, R; fraktur C, H, I, R, Z; double-struck C, H, N, P, Q, R, Z; and italic (serif) h. These gaps cause problems when converting text, as the arithmetic falls into the empty spaces, resulting in blank squares instead of the intended characters. The solution is not cleverness but a lookup table, consulting an explicit exception table before the arithmetic.
The test pangram checks for reserved codepoints, revealing the gaps that cause the tofu output in certain letters. There is no formula to fix the issue, only an explicit exception table to ensure the correct implementation.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.