Base36

{{short description|Binary-to-text encoding scheme}}

{{Refimprove|date=November 2008}}

{{About|an encoding scheme used to represent binary data as text|the positional numeral system using the radix 36|Base 36}}

Base36 is a binary-to-text encoding scheme that represents binary data in an ASCII string format by translating it into a radix-36 representation. The choice of 36 is convenient in that the digits can be represented using the Arabic numerals 0–9 and the Latin letters A–Z{{Citation

| last1 = Hope

| first1 = Paco

| author-link = Paco Hope

| last2 = Walther

| first2 = Ben

| author2-link = Ben Walther

| title = Web Security Testing Cookbook

| publisher = O'Reilly Media, Inc.

| year = 2008

| location = Sebastopol, CA

| volume =

| edition =

| url = https://archive.org/details/websecuritytesti00hope

| doi =

| id =

| isbn = 978-0-596-51483-9

| url-access = registration

}} (the ISO basic Latin alphabet).

Each base36 digit needs less than 6 bits of information to be represented.

Conversion

Signed 32- and 64-bit integers will only hold at most 6 or 13 base-36 digits, respectively (that many base-36 digits can overflow the 32- and 64-bit integers). For example, the 64-bit signed integer maximum value of "9223372036854775807" is "{{mono|1Y2P0IJ32E8E7}}" in base-36.

Similarly, the 32-bit signed integer maximum value of "2147483647" is "{{mono|ZIK0ZJ}}" in base-36.

= Standard implementations =

The C standard library since C89 supports base36 numbers via the strtol and strtoul functions{{Cite web|url=https://en.cppreference.com/w/c/string/byte/strtol|title = strtol, strtoll — cppreference.com}}

In the Common Lisp standard (ANSI INCITS 226-1994), functions like parse-integer support a radix of 2 to 36.{{cite web|url=http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_r.htm#radix|title=Common Lisp HyperSpec|website=LispWorks|access-date=3 August 2022}}

Java SE supports conversion from/to String to different bases from 2 up to 36. For example, [https://docs.oracle.com/javase/8/docs/api/java/lang/Character.html#digit-char-int-] and [https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html#BigInteger-java.lang.String-int-]

Just like Java, JavaScript also supports conversion from/to String to different bases from 2 up to 36. [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString]

PHP, like Java, supports conversion from/to String to different bases from 2 up to 36 using the [https://secure.php.net/manual/en/function.base-convert.php base_convert] function, available since PHP 4.

Go supports conversion to string to different bases from 2 up to 36 using the built-in strconv.FormatInt(), and strconv.FormatUint() functions,{{Cite web|url=https://golang.org/pkg/strconv/#FormatInt|title = Strconv package - strconv - PKG.go.dev}}{{Cite web|url=https://golang.org/pkg/strconv/#FormatUint|title=Strconv package - strconv - PKG.go.dev}} and conversions from string encoded in different bases from 2 up to 36 using the built-in strconv.ParseInt(), and strconv.ParseUint() functions.{{Cite web|url=https://golang.org/pkg/strconv/#ParseInt|title = Strconv package - strconv - PKG.go.dev}}{{Cite web|url=https://golang.org/pkg/strconv/#ParseUint|title = Strconv package - strconv - PKG.go.dev}}

Python allows conversions of strings from base 2 to base 36.{{Cite web|url=https://docs.python.org/3/library/functions.html#int|title = Built-in Functions — Python 3.10.0 documentation}}

Raku supports base2 to base36 for all its real numeric types with its builtins: base{{Cite web|url=https://docs.raku.org/routine/base|title = base}} and parse-base.{{Cite web|url=https://docs.raku.org/type/Str#routine_parse-base|title = routine parse-base}}

See also

References

{{Reflist}}