Skip to main content

Module romaji

Module romaji 

Source
Expand description

Romaji → kana conversion. Hepburn primary; kunrei alternates accepted so users can type si/ti/tu/hu/zi and get the canonical kana.

The table is sorted by pattern-length DESC so the greedy parser can iterate in declaration order and take the first match. Adding new entries: insert in the right length bucket; same-length order is significant only when two patterns share a prefix (longer table pattern always wins regardless of order within bucket).

Functions§

to_hiragana
Render s (a romaji buffer) as hiragana. Unmappable bytes pass through as ASCII so the caller can show partial input to the user while they keep typing. Double-consonant gemination (kk*っk*) is recognized; double-vowel does not produce 促音.
to_katakana
Render s as katakana. Same parser as to_hiragana.