keyboard: the shifted romaji v-row converts fully to katakana
- Commit
1abee617adc3c6d92c2c67465081862388f7b5bb- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 15:02 UTC (4 days ago)
- Parents
3ce8b54
toKatakana converted only U+3041-U+3093 (through n), but the v-row base kana vu is U+3094 — one past the bound — so shifted VA committed mixed-script vu+small-A instead of vu-katakana; VI/VU/VE/VO were the same. The sibling isKana() already uses the full block through U+3096. The range now ends at U+3096 (vu, small-ka, small-ke all have +0x60 katakana parallels). Regression test covers the whole shifted v-row plus unshifted va staying hiragana. Suggestions, clipboard and layout invariants were audited and cleared. Verified: :keyboard: testDevUnitTest 196 tests and lint BUILD SUCCESSFUL.
Diff
keyboard/src/main/java/com/vayunmathur/keyboard/platform/ime/KanaComposers.kt
diff --git a/keyboard/src/main/java/com/vayunmathur/keyboard/platform/ime/KanaComposers.kt b/keyboard/src/main/java/com/vayunmathur/keyboard/platform/ime/KanaComposers.ktindex 792af62f08..062abc0a1e 100644--- a/keyboard/src/main/java/com/vayunmathur/keyboard/platform/ime/KanaComposers.kt+++ b/keyboard/src/main/java/com/vayunmathur/keyboard/platform/ime/KanaComposers.kt@@ -11,9 +11,14 @@ package com.vayunmathur.keyboard.platform.ime * you); it is just not the whole of Japanese input, and the layout descriptions say so. */ -/** Hiragana → katakana: the two blocks are laid out in parallel, 0x60 apart. */+/**+ * Hiragana → katakana: the two blocks are laid out in parallel, 0x60 apart. The+ * hiragana block runs to ゖ (U+3096), not ん (U+3093): the three codepoints past ん —+ * ゔゕゖ — still have katakana parallels (ヴヵヶ), and the romaji `v` row emits ゔ, so+ * stopping at ん left shifted `VA` as the mixed-script ゔァ instead of ヴァ.+ */ private fun toKatakana(text: String): String = buildString {- for (c in text) append(if (c in 'ぁ'..'ん') c + KATAKANA_OFFSET else c)+ for (c in text) append(if (c in 'ぁ'..'ゖ') c + KATAKANA_OFFSET else c) } /** Offset between parallel hiragana and katakana blocks. */
keyboard/src/test/java/com/vayunmathur/keyboard/platform/ime/ComposerTest.kt
diff --git a/keyboard/src/test/java/com/vayunmathur/keyboard/platform/ime/ComposerTest.kt b/keyboard/src/test/java/com/vayunmathur/keyboard/platform/ime/ComposerTest.ktindex bd33c01a9c..de977e26ee 100644--- a/keyboard/src/test/java/com/vayunmathur/keyboard/platform/ime/ComposerTest.kt+++ b/keyboard/src/test/java/com/vayunmathur/keyboard/platform/ime/ComposerTest.kt@@ -135,6 +135,22 @@ class ComposerTest { assertEquals("カタカナ", romaji().type("KATAKANA").finish().text) } + /**+ * Regression: the `v` row's ゔ sits one codepoint past ん, so a hiragana range+ * ending at ん converted the small kana after it but left ゔ itself hiragana —+ * shifted `VA` came out as the mixed-script ゔァ instead of ヴァ.+ */+ @Test+ fun `shift turns the whole v row into katakana`() {+ assertEquals("ヴァ", romaji().type("VA").finish().text)+ assertEquals("ヴィ", romaji().type("VI").finish().text)+ assertEquals("ヴ", romaji().type("VU").finish().text)+ assertEquals("ヴェ", romaji().type("VE").finish().text)+ assertEquals("ヴォ", romaji().type("VO").finish().text)+ // Unshifted, the same spellings stay hiragana.+ assertEquals("ゔぁ", romaji().type("va").finish().text)+ }+ @Test fun `kana keys take the voicing marks`() { assertEquals("が", Field(KanaKeyComposer()).type("か゛").finish().text)