Internationalized Domain Names in Applications (IDNA) for MoonBit
moon add ZSeanYves/MoonIDNAimport {
"ZSeanYves/MoonIDNA/src" @idna,
}fn main {
let ascii = try! @idna.to_ascii("bücher.example")
let unicode = @idna.to_unicode("xn--bcher-kva.example")
println(ascii) // xn--bcher-kva.example
println(unicode) // bücher.example
}fn inspect_domain(domain : StringView) {
let report = @idna.to_unicode_report(domain)
println(report.output)
println(report.errors)
}let strict = try! @idna.to_ascii(
"example.com",
use_std3_ascii_rules=true,
check_hyphens=true,
check_bidi=true,
check_joiners=true,
transitional_processing=false,
verify_dns_length=true,
ignore_invalid_punycode=false,
)let registered = try! @idna.registration_to_ascii("l·l.example")
let report = @idna.registration_to_ascii_report("a·b.example")let policy = @idna.url_policy()
let report = @idna.to_unicode_with_policy("xn--bcher-kva.example", policy)
let (errors, trailing_dot) = @idna.process_labels_with_policy(
"bücher.example.", policy, true,
fn(label) { println(label) },
)python3 tools/build_unicode_blob.py --download --check
python3 tools/build_idna_test_blob.py --checkmoon check --target all
moon test --target wasm-gc
moon test --target wasm
moon test --target js
moon test --target native
moon bench src/unicode_data_bench.mbt --release --target native
moon info && moon fmt
moon package --listInternationalized Domain Names in Applications (IDNA) for MoonBit