summaryrefslogtreecommitdiff
path: root/src/normalize/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/normalize/mod.rs')
-rw-r--r--src/normalize/mod.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/normalize/mod.rs b/src/normalize/mod.rs
new file mode 100644
index 0000000..6294201
--- /dev/null
+++ b/src/normalize/mod.rs
@@ -0,0 +1,36 @@
+mod string;
+
+pub mod nfc {
+ use std::string::String as StdString;
+
+ use unicode_normalization::UnicodeNormalization as _;
+
+ pub type String = super::string::String<Nfc>;
+
+ #[derive(Clone, Debug, Default, Eq, PartialEq)]
+ pub struct Nfc;
+
+ impl super::string::Normalize for Nfc {
+ fn normalize(&self, value: &str) -> StdString {
+ value.nfc().collect()
+ }
+ }
+}
+
+pub mod ident {
+ use std::string::String as StdString;
+
+ use unicode_casefold::UnicodeCaseFold as _;
+ use unicode_normalization::UnicodeNormalization as _;
+
+ pub type String = super::string::String<Ident>;
+
+ #[derive(Clone, Debug, Default, Eq, PartialEq)]
+ pub struct Ident;
+
+ impl super::string::Normalize for Ident {
+ fn normalize(&self, value: &str) -> StdString {
+ value.case_fold().nfkc().collect()
+ }
+ }
+}