From 97bb5a1775245c5b22a1cba14dec2fa2862dcf88 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sun, 26 Mar 2023 19:02:48 +0100 Subject: [PATCH] Use `any_ascii` crate to convert unicode --- Cargo.lock | 16 ++++++++-------- lib/Cargo.toml | 2 +- lib/src/fnc/util/string/mod.rs | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4dde7963..3edce96f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,6 +270,12 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70033777eb8b5124a81a1889416543dddef2de240019b674c81285a2635a7e1e" +[[package]] +name = "any_ascii" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea50b14b7a4b9343f8c627a7a53c52076482bd4bdad0a24fd3ec533ed616cc2c" + [[package]] name = "anyhow" version = "1.0.70" @@ -1056,12 +1062,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "deunicode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1bba4f227a4a53d12b653f50ca7bf10c9119ae2aba56aff9e0338b5c98f36a" - [[package]] name = "digest" version = "0.10.6" @@ -2050,7 +2050,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c09e4591611e231daf4d4c685a66cb0410cc1e502027a20ae55f2bb9e997207a" dependencies = [ - "any_ascii", + "any_ascii 0.1.7", ] [[package]] @@ -3620,6 +3620,7 @@ name = "surrealdb" version = "1.0.0-beta.8" dependencies = [ "addr", + "any_ascii 0.3.2", "argon2", "async-channel", "async-executor", @@ -3627,7 +3628,6 @@ dependencies = [ "bcrypt", "bigdecimal", "chrono", - "deunicode", "dmp", "echodb", "env_logger 0.10.0", diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 50937fd9..05bdfb45 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -52,13 +52,13 @@ targets = [] [dependencies] addr = { version = "0.15.6", default-features = false, features = ["std"] } argon2 = "0.5.0" +ascii = { version = "0.3.2", package = "any_ascii" } async-recursion = "1.0.4" bcrypt = "0.14.0" bigdecimal = { version = "0.3.0", features = ["serde", "string-only"] } channel = { version = "1.8.0", package = "async-channel" } chrono = { version = "0.4.24", features = ["serde"] } derive = { version = "0.5.0", package = "surrealdb-derive" } -deunicode = "1.3.3" dmp = "0.1.2" echodb = { version = "0.3.0", optional = true } executor = { version = "1.5.0", package = "async-executor" } diff --git a/lib/src/fnc/util/string/mod.rs b/lib/src/fnc/util/string/mod.rs index 5a6fd7f6..cee1ce4d 100644 --- a/lib/src/fnc/util/string/mod.rs +++ b/lib/src/fnc/util/string/mod.rs @@ -1,4 +1,4 @@ -use deunicode::deunicode; +use ascii::any_ascii as ascii; use once_cell::sync::Lazy; use regex::Regex; @@ -9,7 +9,7 @@ pub fn slug>(s: S) -> String { // Get a reference let s = s.as_ref(); // Convert unicode to ascii - let mut s = deunicode(s); + let mut s = ascii(s); // Convert string to lowercase s.make_ascii_lowercase(); // Replace any non-simple characters