Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ef7ab4

Browse files
committed
Include missing hiragana/katakana characters
"ぁ"(U+3041), "ゖ"(U+3096) and their counterparts "ァ"(U+30A1), "ヶ"(U+30F6) are not included in the hiragana and katakana conversion range. This commit extend the test cases to check these characters, and fix the conversion range.
1 parent 4269756 commit 0ef7ab4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/kana.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,19 @@ pub fn ascii2wide(s: &str) -> String {
254254
/// Convert Hiragana into Katakana [あ -> ア]
255255
/// # Examples
256256
/// ```
257-
/// assert_eq!("イロハ", kana::hira2kata("いろは"));
257+
/// assert_eq!("イロハァィゥヴヵヶ", kana::hira2kata("いろはぁぃぅゔゕゖ"));
258258
/// ```
259259
pub fn hira2kata(s: &str) -> String {
260-
shift_code(|x| 0x3041 < x && x < 0x3096, |x| x + 0x0060, s)
260+
shift_code(|x| 0x3041 <= x && x <= 0x3096, |x| x + 0x0060, s)
261261
}
262262

263263
/// Convert Katakana into Hiragana [ア -> あ]
264264
/// # Examples
265265
/// ```
266-
/// assert_eq!("いろは", kana::kata2hira("イロハ"));
266+
/// assert_eq!("いろはぁぃぅゔゕゖ", kana::kata2hira("イロハァィゥヴヵヶ"));
267267
/// ```
268268
pub fn kata2hira(s: &str) -> String {
269-
shift_code(|x| 0x30A1 < x && x < 0x30F6, |x| x - 0x0060, s)
269+
shift_code(|x| 0x30A1 <= x && x <= 0x30F6, |x| x - 0x0060, s)
270270
}
271271

272272
macro_rules! push_content {

0 commit comments

Comments
 (0)