An implementation of the bootstring encoding for unicode strings.
Each of the encode
and decode
functions require being passed a
bootstring spec, a map with namespaced keywords for all the parameters to the
bootstring algorithm. The punycode
encoding spec is made available as well
to allow using this standard encoding more easily. If you just need to use
punycode to encode domain names, prefer using methods on [[java.net.IDN]]
which already handles additional work and assertions for converting domain
names.
A bootstring spec consists of the following keys, all of which are namespaced
under bootstring-clj.core
:
The implementation was based on the explanation available on frereit's blog in two parts, one on decoding, and one on encoding.
An implementation of the bootstring encoding for unicode strings. Each of the [[encode]] and [[decode]] functions require being passed a bootstring spec, a map with namespaced keywords for all the parameters to the bootstring algorithm. The [[punycode]] encoding spec is made available as well to allow using this standard encoding more easily. If you just need to use punycode to encode domain names, prefer using methods on [[java.net.IDN]] which already handles additional work and assertions for converting domain names. A bootstring spec consists of the following keys, all of which are namespaced under `bootstring-clj.core`: - ::delimiter a string-encoded regex pattern to match the delimiter (punycode: "-") - ::digits a string with characters at indices representing their encoded value (punycode: "abcdefghijklmnopqrstuvwxyz0123456789") - ::base the numeric base the encoding is based on, should be equal to or smaller than the length of the digits string (punycode: 36) - ::initial-n the lowest codepoint that will be encoded as a delta value (punycode: 128) - ::initial-bias bias value for the generalized variable-length integer threshold function (punycode: 72) - ::tmin the minimum threshold value for generalized variable-length integers (punycode: 1) - ::tmin the maximum threshold value for generalized variable-length integers (punycode: 26) - ::damp the damping value used during the first iteration of adjusting the bias value (punycode: 700) - ::skew a value added to the bias when it is adapted (punycode: 38) The implementation was based on the explanation available on frereit's blog in two parts, one on [decoding](https://frereit.de/bootstring_decoding/), and one on [encoding](https://frereit.de/bootstring_encoding/).
(decode spec string)
Returns a decoded unicode string using the bootstring encoding specified by spec
.
Returns a decoded unicode string using the bootstring encoding specified by `spec`.
(encode spec string)
Returns a bootstring-encoded string using the encoding specified by spec
.
Returns a bootstring-encoded string using the encoding specified by `spec`.
A bootstring spec value for the punycode encoding.
A bootstring spec value for the punycode encoding.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close