kana_transliteration: handle k->h itermark translit, add more tests

This commit is contained in:
2026-06-04 15:49:30 +09:00
parent fb6a018f77
commit df2df5b4ac
3 changed files with 66 additions and 33 deletions
+21
View File
@@ -0,0 +1,21 @@
pub(crate) fn transpose_codepoints_in_range(
text: &str,
distance: i32,
range_start: u32,
range_end: u32,
) -> String {
debug_assert!(range_start <= range_end);
debug_assert!(i64::from(range_start) + i64::from(distance) >= 0);
debug_assert!(i64::from(range_end) + i64::from(distance) <= i64::from(u32::MAX));
text.chars()
.map(|c| {
let codepoint = c as u32;
if range_start <= codepoint && codepoint <= range_end {
std::char::from_u32(codepoint.strict_add_signed(distance)).unwrap_or(c)
} else {
c
}
})
.collect()
}