-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #404 from YuukiToriyama/release/v0.1.13
release/v0.1.13をmainブランチにマージ
- Loading branch information
Showing
9 changed files
with
90 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod converter; | ||
pub(crate) mod extension; | ||
pub mod sequence_matcher; | ||
mod trimmer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
pub(crate) trait CharExt { | ||
fn is_variation_selector(&self) -> bool; | ||
} | ||
|
||
impl CharExt for char { | ||
/// 異字体セレクタかどうかを判別します | ||
fn is_variation_selector(&self) -> bool { | ||
matches!(self, '\u{FE00}'..='\u{FE0F}' | '\u{E0100}'..='\u{E01EF}') | ||
} | ||
} | ||
|
||
pub(crate) trait StrExt { | ||
fn strip_variation_selectors(&self) -> String; | ||
} | ||
|
||
impl StrExt for str { | ||
/// 文字列から異字体セレクタを取り除きます | ||
fn strip_variation_selectors(&self) -> String { | ||
self.chars() | ||
.filter(|c| !c.is_variation_selector()) | ||
.collect() | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::util::extension::{CharExt, StrExt}; | ||
|
||
#[test] | ||
fn is_variation_selector() { | ||
assert_eq!('あ'.is_variation_selector(), false); | ||
assert_eq!('亜'.is_variation_selector(), false); | ||
|
||
assert_eq!('\u{FDFF}'.is_variation_selector(), false); | ||
assert_eq!('\u{FE00}'.is_variation_selector(), true); | ||
|
||
assert_eq!('\u{FE0F}'.is_variation_selector(), true); | ||
assert_eq!('\u{FE10}'.is_variation_selector(), false); | ||
|
||
assert_eq!('\u{E00FF}'.is_variation_selector(), false); | ||
assert_eq!('\u{E0100}'.is_variation_selector(), true); | ||
|
||
assert_eq!('\u{E01EF}'.is_variation_selector(), true); | ||
assert_eq!('\u{E01F0}'.is_variation_selector(), false); | ||
} | ||
|
||
#[test] | ||
fn strip_variation_selectors_逢坂() { | ||
let normal = "\u{9022}\u{5742}"; // 逢坂 | ||
let variant = "\u{9022}\u{E0101}\u{5742}"; // 逢󠄁坂 | ||
assert_ne!(normal, variant); | ||
assert_eq!(normal, variant.strip_variation_selectors()); | ||
} | ||
|
||
#[test] | ||
fn strip_variation_selectors_茨城() { | ||
let normal = "\u{8328}\u{57CE}"; | ||
let variant = "\u{8328}\u{E0100}\u{57CE}"; | ||
assert_ne!(normal, variant); | ||
assert_eq!(normal, variant.strip_variation_selectors()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
address,prefecture,city,town,rest | ||
東京都葛飾区立石5-13-1,東京都,葛飾区,立石五丁目,13-1 | ||
東京都葛󠄀飾区立石5-13-1,東京都,葛飾区,立石五丁目,13-1 | ||
奈良県葛城市柿本166番地,奈良県,葛城市,柿本,166番地 | ||
奈良県葛󠄀城市柿本166番地,奈良県,葛城市,柿本,166番地 | ||
鹿児島県薩摩川内市上甑町中甑250-1,鹿児島県,薩摩川内市,上甑町中甑,250-1 | ||
鹿児島県薩摩川内市上甑󠄀町中甑󠄀250-1,鹿児島県,薩摩川内市,上甑町中甑,250-1 |