Skip to content
Tcl Source Code Artifact [2a17879b8f]
Login

Artifact [2a17879b8f]

Artifact 2a17879b8f7933ddf04190571bfe0bc6a2ad45ade401587eff35f3b6f90beaeb:



CommandName: idna ManualSection: n Version: 0.1 TclPart: http TclDescription: Tcl Bundled Packages Links:

Name

tcl::idna - Support for normalization of Internationalized Domain Names

Synopsis

::: {.synopsis} ::: [package]{.cmd} [require]{.sub} [tcl::idna]{.lit} [1.0]{.lit}

[tcl::idna]{.cmd} [decode]{.sub} [hostname]{.arg} [tcl::idna]{.cmd} [encode]{.sub} [hostname]{.arg} [tcl::idna]{.cmd} [puny]{.sub} [decode]{.lit} [string]{.arg} [case]{.optarg} [tcl::idna]{.cmd} [puny]{.sub} [encode]{.lit} [string]{.arg} [case]{.optarg} [tcl::idna]{.cmd} [version]{.sub} :::

Description

This package provides an implementation of the punycode scheme used in Internationalised Domain Names, and some access commands. (See RFC 3492 for a description of punycode.)

tcl::idna decode fIhostnamefR : This command takes the name of a host that potentially contains punycode-encoded character sequences, fIhostnamefR, and returns the hostname as might be displayed to the user. Note that there are often UNICODE characters that have extremely similar glyphs, so care should be taken with displaying hostnames to users.

tcl::idna encode fIhostnamefR : This command takes the name of a host as might be displayed to the user, fIhostnamefR, and returns the version of the hostname with characters not permitted in basic hostnames encoded with punycode.

tcl::idna puny fIsubcommand ...fR : This command provides direct access to the basic punycode encoder and decoder. It supports two fIsubcommandfRs:

tcl::idna puny decode fIstringfR ?fIcasefR? : This command decodes the punycode-encoded string, fIstringfR, and returns the result. If fIcasefR is provided, it is a boolean to make the case be folded to upper case (if fIcasefR is true) or lower case (if fIcasefR is false) during the decoding process; if omitted, no case transformation is applied.

tcl::idna puny encode fIstringfR ?fIcasefR? : This command encodes the string, fIstringfR, and returns the punycode-encoded version of the string. If fIcasefR is provided, it is a boolean to make the case be folded to upper case (if fIcasefR is true) or lower case (if fIcasefR is false) during the encoding process; if omitted, no case transformation is applied.

tcl::idna version : This returns the version of the fBtcl::idnafR package.

Example

This is an example of how punycoding of a string works:

package require tcl::idna

puts [tcl::idna puny encode "abc\(->def"]
#    prints: abcdef-kn2c
puts [tcl::idna puny decode "abcdef-kn2c"]
#    prints: abc\(->def