Skip to content

Commit 7ccf2fc

Browse files
committed
Use unicode-properties
1 parent 5d8183f commit 7ccf2fc

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ readme = "README.md"
1010
[dependencies]
1111
unicode-bidi = "0.3"
1212
unicode-normalization = "0.1"
13+
unicode-properties = "0.1.1"

src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
#![warn(missing_docs)]
55
extern crate unicode_bidi;
66
extern crate unicode_normalization;
7+
extern crate unicode_properties;
78

89
use std::borrow::Cow;
910
use std::fmt;
1011
use unicode_normalization::UnicodeNormalization;
12+
use unicode_properties::GeneralCategory;
1113

1214
mod rfc3454;
1315
pub mod tables;
@@ -351,7 +353,7 @@ pub fn x520prep(s: &str, case_fold: bool) -> Result<Cow<'_, str>, Error> {
351353
// "The first code point of a string is prohibited from being a combining character."
352354
match s.chars().next() {
353355
Some(c) => {
354-
if c.is_mark() {
356+
if c.general_category_group() == GeneralCategoryGroup::Mark {
355357
return Err(Error(ErrorCause::StartsWithCombiningCharacter));
356358
}
357359
}

src/tables.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
use std::cmp::Ordering;
33
use std::str::Chars;
44
use unicode_bidi::{bidi_class, BidiClass};
5+
use unicode_properties::GeneralCategory;
56

67
use super::rfc3454;
78

@@ -245,6 +246,6 @@ pub fn x520_mapped_to_nothing(c: char) -> bool {
245246
pub fn x520_mapped_to_space(c: char) -> bool {
246247
match c {
247248
'\u{09}' | '\u{0A}'..='\u{0D}' | '\u{85}' => true,
248-
_ => c.is_separator(),
249+
_ => c.general_category_group() == GeneralCategoryGroup::Separator,
249250
}
250251
}

0 commit comments

Comments
 (0)