diff --git a/common.mbt b/common.mbt index 45b8e84..ef475a1 100644 --- a/common.mbt +++ b/common.mbt @@ -21,10 +21,12 @@ let initial_bias : UInt = 72U ///| let initial_n : UInt = 0x80U // 128 -///| Delimiter between literal portion and encoded portion +///| +/// Delimiter between literal portion and encoded portion let delimiter : Char = '-' -///| Bias adaptation function +///| +/// Bias adaptation function fn adapt(delta : UInt, num_points : UInt, first_time : Bool) -> UInt { let mut delta = delta delta /= if first_time { damp } else { 2U } diff --git a/decode.mbt b/decode.mbt index 51ec2bb..747ef19 100644 --- a/decode.mbt +++ b/decode.mbt @@ -1,4 +1,5 @@ -///| Converts a Punycode string of ASCII-only symbols to a string of Unicode symbols. +///| +/// Converts a Punycode string of ASCII-only symbols to a string of Unicode symbols. pub fn decode(encoded : String) -> String? { let decoded = [] let encoded_length = encoded.length().reinterpret_as_uint() diff --git a/encode.mbt b/encode.mbt index 689305f..1eef63f 100644 --- a/encode.mbt +++ b/encode.mbt @@ -1,4 +1,5 @@ -///| Convert a string of Unicode symbols to a Punycode string of ASCII-only symbols. +///| +/// Convert a string of Unicode symbols to a Punycode string of ASCII-only symbols. pub fn encode(raw : String) -> String? { // Basic code point segregation, extract ASCII characters that are // encoded as-is @@ -18,7 +19,7 @@ pub fn encode(raw : String) -> String? { // let m = the minimum {non-basic} code point >= n in the input let mut m = @uint.max_value for j = 0U; j < input_lenght; j = j + 1U { - let code = raw[j.reinterpret_as_int()].reinterpret_as_uint() + let code = raw[j.reinterpret_as_int()].to_uint() if code >= n && code < m { m = code } @@ -29,7 +30,7 @@ pub fn encode(raw : String) -> String? { delta += (m - n) * (h + 1) n = m for j = 0U; j < input_lenght; j = j + 1U { - let code = raw[j.reinterpret_as_int()].reinterpret_as_uint() + let code = raw[j.reinterpret_as_int()].to_uint() if code < n { delta += 1 if delta == 0 { diff --git a/pkg.generated.mbti b/pkg.generated.mbti new file mode 100644 index 0000000..df6758f --- /dev/null +++ b/pkg.generated.mbti @@ -0,0 +1,16 @@ +// Generated using `moon info`, DON'T EDIT IT +package "chawyehsu/punycode" + +// Values +pub fn decode(String) -> String? + +pub fn encode(String) -> String? + +// Errors + +// Types and methods + +// Type aliases + +// Traits +