idna.bend checks
raw source on the hub · import 0x00e7af2de246c3a4c341d9ee49e68747/idna.bend as Idna
Punycode (RFC 3492) and A-labels (RFC 5890): a domain with non-ASCII labels written as "xn--" ASCII, so it can travel where only ASCII may (an SMTP session without SMTPUTF8).
Not done: the IDNA2008 mapping and checks (Unicode normalization, case folding of non-ASCII letters, the disallowed code points). A label is converted as written; ASCII letters are lower-cased.
1 import
import Base
Types
type Pc source · line 12 · raw
Data
The state of an encoding: delta, bias, the code points handled (h), the basic ones (b), the next code point to place (n), the output.
Pc@delta:U32 -> @bias:U32 -> @h:U32 -> @b:U32 -> @n:U32 -> @out:String -> Pc
Definitions
def Puny.pick source · line 15 · raw
@c:Bool -> @a:U32 -> @b:U32 -> U32
def Puny.digit source · line 23 · raw
@+d:U32 -> Char
Digit d (0..35) as a..z, 0..9.
def Puny.t source · line 27 · raw
@+k:U32 -> @+bias:U32 -> U32
The threshold t for position k (tmin 1, tmax 26).
def Puny.vli.at source · line 31 · raw
@stop:Bool -> @+q:U32 -> @+t:U32 -> @more:(@_:U32 -> String) -> String
def Puny.vli source · line 39 · raw
@fuel:Nat -> @+q:U32 -> @+k:U32 -> @+bias:U32 -> String
q as a generalized variable-length integer (RFC 3492 3.3).
def Puny.adapt.go source · line 47 · raw
@fuel:Nat -> @+d:U32 -> @+k:U32 -> U32
def Puny.adapt source · line 56 · raw
@+delta:U32 -> @+num:U32 -> @first:Bool -> U32
The bias adaptation (RFC 3492 6.1).
def Puny.char source · line 60 · raw
@+c:U32 -> @+n:U32 -> @st:Pc -> Pc
def Puny.chars source · line 68 · raw
@cs:List<&2, U32> -> @+n:U32 -> @st:Pc -> Pc
def Puny.min source · line 76 · raw
@cs:List<&2, U32> -> @+n:U32 -> @+best:U32 -> U32
The smallest code point >= n.
def Puny.next source · line 83 · raw
@st:Pc -> @+m:U32 -> Pc
def Puny.round source · line 88 · raw
@+cs:List<&2, U32> -> @st:Pc -> Pc
One round: the next code point placed at every position.
def Puny.more source · line 94 · raw
@done:Bool -> @st:Pc -> @next:(@_:Pc -> String) -> String
def Puny.go source · line 102 · raw
@fuel:Nat -> @+cs:List<&2, U32> -> @+len:U32 -> @+st:Pc -> String
def Puny.keep source · line 111 · raw
@yes:Bool -> @c:U32 -> @rest:String -> String
def Puny.basic source · line 118 · raw
@cs:List<&2, U32> -> String
def Puny.count source · line 125 · raw
@cs:List<&2, U32> -> U32
def Puny.encode source · line 133 · raw
@+cs:List<&2, U32> -> String
The Punycode of a list of code points.
def Idna.codes source · line 142 · raw
@s:String -> List<&2, U32>
def Idna.ascii source · line 149 · raw
@s:String -> Bool
def Idna.label.at source · line 156 · raw
@ascii:Bool -> @l:String -> String
def Idna.label source · line 164 · raw
@+l:String -> String
A label as an A-label when it has non-ASCII, else as it is.
def Idna.labels source · line 167 · raw
@ls:List<&2, String> -> List<&2, String>
def Idna.domain source · line 175 · raw
@d:String -> String
A domain with every non-ASCII label as an A-label.