Char.Ascii(3) OCaml library Char.Ascii(3)

# [NAME](#NAME)

Char.Ascii - ASCII character set support.

# [Module](#Module)

Module Char.Ascii

# [Documentation](#Documentation)

Module **Ascii**  
: **sig end**

ASCII character set support.

These functions give meaning to the integers \[ **0x00** ; **0x7F** ] of the ASCII character set.

Since the UTF-8 encoding of Unicode has the same encoding and character semantics (U+0000 to U+001F) for these bytes, the functions can be safely used on elements of UTF-8 encoded **string** and **bytes** values. However the functions only deal with ASCII related matters. For example the notion of Unicode whitespace is much larger than the ASCII whitespace determined by **Char.Ascii.is\_white** .

**Since** 5.4

## [Characters](#Characters)

*val min* : **char**

**min** is **'\\x00'** .

*val max* : **char**

**max** is **'\\x7F'** .

## [Predicates](#Predicates)

*val is\_valid* : **char -&gt; bool**

**is\_valid c** is **true** if and only if **c** is an ASCII character, that is a byte in the range \[ **Char.Ascii.min** ; **Char.Ascii.max** ].

*val is\_upper* : **char -&gt; bool**

**is\_upper c** is **true** if and only if **c** is an ASCII uppercase letter **'A'** to **'Z'** , that is a byte in the range \[ **0x41** ; **0x5A** ].

*val is\_lower* : **char -&gt; bool**

**is\_lower c** is **true** if and only if **c** is an ASCII lowercase letter **'a'** to **'z'** , that is a byte in the range \[ **0x61** ; **0x7A** ].

*val is\_letter* : **char -&gt; bool**

**is\_letter c** is **Char.Ascii.is\_lower** **c ||** **Char.Ascii.is\_upper** **c** .

*val is\_alphanum* : **char -&gt; bool**

**is\_alphanum c** is **Char.Ascii.is\_letter** **c ||** **Char.Ascii.is\_digit** **c** .

*val is\_white* : **char -&gt; bool**

**is\_white c** is **true** if and only if **c** is an ASCII white space character, that is one of tab **'\\t'** ( **0x09** ), newline **'\\n'** ( **0x0A** ), vertical tab ( **0x0B** ), form feed ( **0x0C** ), carriage return **'\\r'** ( **0x0D** ) or space **' '** ( **0x20** ),

*val is\_blank* : **char -&gt; bool**

**is\_blank c** is **true** if and only if **c** is an ASCII blank character, that is either space **' '** ( **0x20** ) or tab **'\\t'** ( **0x09** ).

*val is\_graphic* : **char -&gt; bool**

**is\_graphic c** is **true** if and only if **c** is an ASCII graphic character, that is a byte in the range \[ **0x21** ; **0x7E** ].

*val is\_print* : **char -&gt; bool**

**is\_print c** is **Char.Ascii.is\_graphic** **c || c = ' '** .

*val is\_control* : **char -&gt; bool**

**is\_control c** is **true** if and only if **c** is an ASCII control character, that is a byte in the range \[ **0x00** ; **0x1F** ] or **0x7F** .

## [Decimal digits](#Decimal_digits)

*val is\_digit* : **char -&gt; bool**

**is\_digit c** is **true** if and only if **c** is an ASCII decimal digit **'0'** to **'9'** , that is a byte in the range \[ **0x30** ; **0x39** ].

*val digit\_to\_int* : **char -&gt; int**

**digit\_to\_int c** is the numerical value of a digit that satisfies **Char.Ascii.is\_digit** . Raises **Invalid\_argument** if **Char.Ascii.is\_digit** **c** is **false** .

*val digit\_of\_int* : **int -&gt; char**

**digit\_of\_int n** is an ASCII decimal digit for the decimal value **abs (n mod 10)** .

## [Hexadecimal digits](#Hexadecimal_digits)

*val is\_hex\_digit* : **char -&gt; bool**

**is\_hex\_digit c** is **true** if and only if **c** is an ASCII hexadecimal digit **'0'** to **'9'** , **'a'** to **'f'** or **'A'** to **'F'** , that is a byte in one of the ranges \[ **0x30** ; **0x39** ], \[ **0x41** ; **0x46** ], \[ **0x61** ; **0x66** ].

*val hex\_digit\_to\_int* : **char -&gt; int**

**hex\_digit\_to\_int c** is the numerical value of a digit that satisfies **Char.Ascii.is\_hex\_digit** . Raises **Invalid\_argument** if **Char.Ascii.is\_hex\_digit** **c** is **false** .

*val lower\_hex\_digit\_of\_int* : **int -&gt; char**

**lower\_hex\_digit\_of\_int n** is a lowercase ASCII hexadecimal digit for the hexadecimal value **abs (n mod 16)** .

*val upper\_hex\_digit\_of\_int* : **int -&gt; char**

**upper\_hex\_digit\_of\_int n** is an uppercase ASCII hexadecimal digit for the hexadecimal value **abs (n mod 16)** .

## [Casing transforms](#Casing_transforms)

*val uppercase* : **char -&gt; char**

**uppercase c** is **c** with ASCII characters **'a'** to **'z'** respectively mapped to uppercase characters **'A'** to **'Z'** . Other characters are left untouched.

*val lowercase* : **char -&gt; char**

**lowercase c** is **c** with ASCII characters **'A'** to **'Z'** respectively mapped to lowercase characters **'a'** to **'z'** . Other characters are left untouched.

2026-10-23 OCamldoc

---

Document: Char.Ascii(3o) from ocaml 5.5.2-r0 (Chainguard OS)
Source: https://github.com/ocaml/ocaml
