Use any_ascii crate to convert unicode

This commit is contained in:
Tobie Morgan Hitchcock 2023-03-26 19:02:48 +01:00
parent cad596cdf3
commit 97bb5a1775
3 changed files with 11 additions and 11 deletions

16
Cargo.lock generated
View file

@ -270,6 +270,12 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70033777eb8b5124a81a1889416543dddef2de240019b674c81285a2635a7e1e" checksum = "70033777eb8b5124a81a1889416543dddef2de240019b674c81285a2635a7e1e"
[[package]]
name = "any_ascii"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea50b14b7a4b9343f8c627a7a53c52076482bd4bdad0a24fd3ec533ed616cc2c"
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.70" version = "1.0.70"
@ -1056,12 +1062,6 @@ dependencies = [
"syn 1.0.109", "syn 1.0.109",
] ]
[[package]]
name = "deunicode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c1bba4f227a4a53d12b653f50ca7bf10c9119ae2aba56aff9e0338b5c98f36a"
[[package]] [[package]]
name = "digest" name = "digest"
version = "0.10.6" version = "0.10.6"
@ -2050,7 +2050,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c09e4591611e231daf4d4c685a66cb0410cc1e502027a20ae55f2bb9e997207a" checksum = "c09e4591611e231daf4d4c685a66cb0410cc1e502027a20ae55f2bb9e997207a"
dependencies = [ dependencies = [
"any_ascii", "any_ascii 0.1.7",
] ]
[[package]] [[package]]
@ -3620,6 +3620,7 @@ name = "surrealdb"
version = "1.0.0-beta.8" version = "1.0.0-beta.8"
dependencies = [ dependencies = [
"addr", "addr",
"any_ascii 0.3.2",
"argon2", "argon2",
"async-channel", "async-channel",
"async-executor", "async-executor",
@ -3627,7 +3628,6 @@ dependencies = [
"bcrypt", "bcrypt",
"bigdecimal", "bigdecimal",
"chrono", "chrono",
"deunicode",
"dmp", "dmp",
"echodb", "echodb",
"env_logger 0.10.0", "env_logger 0.10.0",

View file

@ -52,13 +52,13 @@ targets = []
[dependencies] [dependencies]
addr = { version = "0.15.6", default-features = false, features = ["std"] } addr = { version = "0.15.6", default-features = false, features = ["std"] }
argon2 = "0.5.0" argon2 = "0.5.0"
ascii = { version = "0.3.2", package = "any_ascii" }
async-recursion = "1.0.4" async-recursion = "1.0.4"
bcrypt = "0.14.0" bcrypt = "0.14.0"
bigdecimal = { version = "0.3.0", features = ["serde", "string-only"] } bigdecimal = { version = "0.3.0", features = ["serde", "string-only"] }
channel = { version = "1.8.0", package = "async-channel" } channel = { version = "1.8.0", package = "async-channel" }
chrono = { version = "0.4.24", features = ["serde"] } chrono = { version = "0.4.24", features = ["serde"] }
derive = { version = "0.5.0", package = "surrealdb-derive" } derive = { version = "0.5.0", package = "surrealdb-derive" }
deunicode = "1.3.3"
dmp = "0.1.2" dmp = "0.1.2"
echodb = { version = "0.3.0", optional = true } echodb = { version = "0.3.0", optional = true }
executor = { version = "1.5.0", package = "async-executor" } executor = { version = "1.5.0", package = "async-executor" }

View file

@ -1,4 +1,4 @@
use deunicode::deunicode; use ascii::any_ascii as ascii;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
@ -9,7 +9,7 @@ pub fn slug<S: AsRef<str>>(s: S) -> String {
// Get a reference // Get a reference
let s = s.as_ref(); let s = s.as_ref();
// Convert unicode to ascii // Convert unicode to ascii
let mut s = deunicode(s); let mut s = ascii(s);
// Convert string to lowercase // Convert string to lowercase
s.make_ascii_lowercase(); s.make_ascii_lowercase();
// Replace any non-simple characters // Replace any non-simple characters