moonpool/dev/ocaml/Stdlib/String/index.html

6 lines
No EOL
52 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>String (ocaml.Stdlib.String)</title><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../../index.html">ocaml</a> &#x00BB; <a href="../index.html">Stdlib</a> &#x00BB; String</nav><header class="odoc-preamble"><h1>Module <code><span>Stdlib.String</span></code></h1><p>Strings.</p><p>A string <code>s</code> of length <code>n</code> is an indexable and immutable sequence of <code>n</code> bytes. For historical reasons these bytes are referred to as characters.</p><p>The semantics of string functions is defined in terms of indices and positions. These are depicted and described as follows.</p><pre>positions 0 1 2 3 4 n-1 n
+---+---+---+---+ +-----+
indices | 0 | 1 | 2 | 3 | ... | n-1 |
+---+---+---+---+ +-----+</pre><ul><li>An <em>index</em> <code>i</code> of <code>s</code> is an integer in the range [<code>0</code>;<code>n-1</code>]. It represents the <code>i</code>th byte (character) of <code>s</code> which can be accessed using the constant time string indexing operator <code>s.[i]</code>.</li><li>A <em>position</em> <code>i</code> of <code>s</code> is an integer in the range [<code>0</code>;<code>n</code>]. It represents either the point at the beginning of the string, or the point between two indices, or the point at the end of the string. The <code>i</code>th byte index is between position <code>i</code> and <code>i+1</code>.</li></ul><p>Two integers <code>start</code> and <code>len</code> are said to define a <em>valid substring</em> of <code>s</code> if <code>len &gt;= 0</code> and <code>start</code>, <code>start+len</code> are positions of <code>s</code>.</p><p><b>Unicode text.</b> Strings being arbitrary sequences of bytes, they can hold any kind of textual encoding. However the recommended encoding for storing Unicode text in OCaml strings is UTF-8. This is the encoding used by Unicode escapes in string literals. For example the string <code>&quot;\u{1F42B}&quot;</code> is the UTF-8 encoding of the Unicode character U+1F42B.</p><p><b>Past mutability.</b> OCaml strings used to be modifiable in place, for instance via the <a href="#val-set"><code>String.set</code></a> and <a href="#val-blit"><code>String.blit</code></a> functions. This use is nowadays only possible when the compiler is put in &quot;unsafe-string&quot; mode by giving the <code>-unsafe-string</code> command-line option. This compatibility mode makes the types <code>string</code> and <code>bytes</code> (see <a href="../Bytes/index.html#type-t"><code>Bytes.t</code></a>) interchangeable so that functions expecting byte sequences can also accept strings as arguments and modify them.</p><p>The distinction between <code>bytes</code> and <code>string</code> was introduced in OCaml 4.02, and the &quot;unsafe-string&quot; compatibility mode was the default until OCaml 4.05. Starting with 4.06, the compatibility mode is opt-in; we intend to remove the option in the future.</p><p>The labeled version of this module can be used as described in the <a href="../StdLabels/index.html"><code>StdLabels</code></a> module.</p></header><nav class="odoc-toc"><ul><li><a href="#strings">Strings</a></li><li><a href="#concat">Concatenating</a></li><li><a href="#predicates">Predicates and comparisons</a></li><li><a href="#extract">Extracting substrings</a></li><li><a href="#transforming">Transforming</a></li><li><a href="#traversing">Traversing</a></li><li><a href="#searching">Searching</a></li><li><a href="#strings-and-sequences">Strings and Sequences</a></li><li><a href="#utf">UTF decoding and validations</a><ul><li><a href="#utf_8">UTF-8</a></li><li><a href="#utf_16be">UTF-16BE</a></li><li><a href="#utf_16le">UTF-16LE</a></li></ul></li><li><a href="#deprecated">Deprecated functions</a></li><li><a href="#binary-decoding-of-integers">Binary decoding of integers</a></li></ul></nav><div class="odoc-content"><h2 id="strings"><a href="#strings" class="anchor"></a>Strings</h2><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span><span> = string</span></code></div><div class="spec-doc"><p>The type for strings.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-make"><a href="#val-make" class="anchor"></a><code><span><span class="keyword">val</span> make : <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>make n c</code> is a string of length <code>n</code> with each index holding the character <code>c</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>n &lt; 0</code> or <code>n &gt; </code><a href="../Sys/index.html#val-max_string_length"><code>Sys.max_string_length</code></a>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-init"><a href="#val-init" class="anchor"></a><code><span><span class="keyword">val</span> init : <span>int <span class="arrow">&#45;&gt;</span></span> <span><span>(<span>int <span class="arrow">&#45;&gt;</span></span> char)</span> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>init n f</code> is a string of length <code>n</code> with index <code>i</code> holding the character <code>f i</code> (called in increasing index order).</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>n &lt; 0</code> or <code>n &gt; </code><a href="../Sys/index.html#val-max_string_length"><code>Sys.max_string_length</code></a>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.02.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-empty"><a href="#val-empty" class="anchor"></a><code><span><span class="keyword">val</span> empty : string</span></code></div><div class="spec-doc"><p>The empty string.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-of_bytes"><a href="#val-of_bytes" class="anchor"></a><code><span><span class="keyword">val</span> of_bytes : <span>bytes <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Return a new string that contains the same bytes as the given byte sequence.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-to_bytes"><a href="#val-to_bytes" class="anchor"></a><code><span><span class="keyword">val</span> to_bytes : <span>string <span class="arrow">&#45;&gt;</span></span> bytes</span></code></div><div class="spec-doc"><p>Return a new byte sequence that contains the same bytes as the given string.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value external anchored" id="val-length"><a href="#val-length" class="anchor"></a><code><span><span class="keyword">val</span> length : <span>string <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>length s</code> is the length (number of bytes/characters) of <code>s</code>.</p></div></div><div class="odoc-spec"><div class="spec value external anchored" id="val-get"><a href="#val-get" class="anchor"></a><code><span><span class="keyword">val</span> get : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> char</span></code></div><div class="spec-doc"><p><code>get s i</code> is the character at index <code>i</code> in <code>s</code>. This is the same as writing <code>s.[i]</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>i</code> not an index of <code>s</code>.</p></li></ul></div></div><h2 id="concat"><a href="#concat" class="anchor"></a>Concatenating</h2><p><b>Note.</b> The <a href="../index.html#val-(^)"><code>Stdlib.(^)</code></a> binary operator concatenates two strings.</p><div class="odoc-spec"><div class="spec value anchored" id="val-concat"><a href="#val-concat" class="anchor"></a><code><span><span class="keyword">val</span> concat : <span>string <span class="arrow">&#45;&gt;</span></span> <span><span>string list</span> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>concat sep ss</code> concatenates the list of strings <code>ss</code>, inserting the separator string <code>sep</code> between each.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if the result is longer than <a href="../Sys/index.html#val-max_string_length"><code>Sys.max_string_length</code></a> bytes.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-cat"><a href="#val-cat" class="anchor"></a><code><span><span class="keyword">val</span> cat : <span>string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>cat s1 s2</code> concatenates s1 and s2 (<code>s1 ^ s2</code>).</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if the result is longer than <a href="../Sys/index.html#val-max_string_length"><code>Sys.max_string_length</code></a> bytes.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><h2 id="predicates"><a href="#predicates" class="anchor"></a>Predicates and comparisons</h2><div class="odoc-spec"><div class="spec value anchored" id="val-equal"><a href="#val-equal" class="anchor"></a><code><span><span class="keyword">val</span> equal : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>equal s0 s1</code> is <code>true</code> if and only if <code>s0</code> and <code>s1</code> are character-wise equal.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.03.0 (4.05.0 in StringLabels)</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-compare"><a href="#val-compare" class="anchor"></a><code><span><span class="keyword">val</span> compare : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>compare s0 s1</code> sorts <code>s0</code> and <code>s1</code> in lexicographical order. <code>compare</code> behaves like <a href="../index.html#val-compare"><code>Stdlib.compare</code></a> on strings but may be more efficient.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-starts_with"><a href="#val-starts_with" class="anchor"></a><code><span><span class="keyword">val</span> starts_with : <span>prefix:string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>starts_with </code><code>~prefix s</code> is <code>true</code> if and only if <code>s</code> starts with <code>prefix</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-ends_with"><a href="#val-ends_with" class="anchor"></a><code><span><span class="keyword">val</span> ends_with : <span>suffix:string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>ends_with </code><code>~suffix s</code> is <code>true</code> if and only if <code>s</code> ends with <code>suffix</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-contains_from"><a href="#val-contains_from" class="anchor"></a><code><span><span class="keyword">val</span> contains_from : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>contains_from s start c</code> is <code>true</code> if and only if <code>c</code> appears in <code>s</code> after position <code>start</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>start</code> is not a valid position in <code>s</code>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-rcontains_from"><a href="#val-rcontains_from" class="anchor"></a><code><span><span class="keyword">val</span> rcontains_from : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>rcontains_from s stop c</code> is <code>true</code> if and only if <code>c</code> appears in <code>s</code> before position <code>stop+1</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>stop &lt; 0</code> or <code>stop+1</code> is not a valid position in <code>s</code>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-contains"><a href="#val-contains" class="anchor"></a><code><span><span class="keyword">val</span> contains : <span>string <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>contains s c</code> is <a href="#val-contains_from"><code>String.contains_from</code></a><code> s 0 c</code>.</p></div></div><h2 id="extract"><a href="#extract" class="anchor"></a>Extracting substrings</h2><div class="odoc-spec"><div class="spec value anchored" id="val-sub"><a href="#val-sub" class="anchor"></a><code><span><span class="keyword">val</span> sub : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>sub s pos len</code> is a string of length <code>len</code>, containing the substring of <code>s</code> that starts at position <code>pos</code> and has length <code>len</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>pos</code> and <code>len</code> do not designate a valid substring of <code>s</code>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-split_on_char"><a href="#val-split_on_char" class="anchor"></a><code><span><span class="keyword">val</span> split_on_char : <span>char <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span>string list</span></span></code></div><div class="spec-doc"><p><code>split_on_char sep s</code> is the list of all (possibly empty) substrings of <code>s</code> that are delimited by the character <code>sep</code>.</p><p>The function's result is specified by the following invariants:</p><ul><li>The list is not empty.</li><li>Concatenating its elements using <code>sep</code> as a separator returns a string equal to the input (<code>concat (make 1 sep)
(split_on_char sep s) = s</code>).</li><li>No string in the result contains the <code>sep</code> character.</li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.04.0 (4.05.0 in StringLabels)</li></ul></div></div><h2 id="transforming"><a href="#transforming" class="anchor"></a>Transforming</h2><div class="odoc-spec"><div class="spec value anchored" id="val-map"><a href="#val-map" class="anchor"></a><code><span><span class="keyword">val</span> map : <span><span>(<span>char <span class="arrow">&#45;&gt;</span></span> char)</span> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>map f s</code> is the string resulting from applying <code>f</code> to all the characters of <code>s</code> in increasing order.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.00.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-mapi"><a href="#val-mapi" class="anchor"></a><code><span><span class="keyword">val</span> mapi : <span><span>(<span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> char)</span> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>mapi f s</code> is like <a href="#val-map"><code>map</code></a> but the index of the character is also passed to <code>f</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.02.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-fold_left"><a href="#val-fold_left" class="anchor"></a><code><span><span class="keyword">val</span> fold_left : <span><span>(<span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span></span></code></div><div class="spec-doc"><p><code>fold_left f x s</code> computes <code>f (... (f (f x s.[0]) s.[1]) ...) s.[n-1]</code>, where <code>n</code> is the length of the string <code>s</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-fold_right"><a href="#val-fold_right" class="anchor"></a><code><span><span class="keyword">val</span> fold_right : <span><span>(<span>char <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span></span></code></div><div class="spec-doc"><p><code>fold_right f s x</code> computes <code>f s.[0] (f s.[1] ( ... (f s.[n-1] x) ...))</code>, where <code>n</code> is the length of the string <code>s</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-for_all"><a href="#val-for_all" class="anchor"></a><code><span><span class="keyword">val</span> for_all : <span><span>(<span>char <span class="arrow">&#45;&gt;</span></span> bool)</span> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>for_all p s</code> checks if all characters in <code>s</code> satisfy the predicate <code>p</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-exists"><a href="#val-exists" class="anchor"></a><code><span><span class="keyword">val</span> exists : <span><span>(<span>char <span class="arrow">&#45;&gt;</span></span> bool)</span> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>exists p s</code> checks if at least one character of <code>s</code> satisfies the predicate <code>p</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-trim"><a href="#val-trim" class="anchor"></a><code><span><span class="keyword">val</span> trim : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>trim s</code> is <code>s</code> without leading and trailing whitespace. Whitespace characters are: <code>' '</code>, <code>'\x0C'</code> (form feed), <code>'\n'</code>, <code>'\r'</code>, and <code>'\t'</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.00.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-escaped"><a href="#val-escaped" class="anchor"></a><code><span><span class="keyword">val</span> escaped : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>escaped s</code> is <code>s</code> with special characters represented by escape sequences, following the lexical conventions of OCaml.</p><p>All characters outside the US-ASCII printable range [0x20;0x7E] are escaped, as well as backslash (0x2F) and double-quote (0x22).</p><p>The function <a href="../Scanf/index.html#val-unescaped"><code>Scanf.unescaped</code></a> is a left inverse of <code>escaped</code>, i.e. <code>Scanf.unescaped (escaped s) = s</code> for any string <code>s</code> (unless <code>escaped s</code> fails).</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if the result is longer than <a href="../Sys/index.html#val-max_string_length"><code>Sys.max_string_length</code></a> bytes.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-uppercase_ascii"><a href="#val-uppercase_ascii" class="anchor"></a><code><span><span class="keyword">val</span> uppercase_ascii : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>uppercase_ascii s</code> is <code>s</code> with all lowercase letters translated to uppercase, using the US-ASCII character set.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.03.0 (4.05.0 in StringLabels)</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-lowercase_ascii"><a href="#val-lowercase_ascii" class="anchor"></a><code><span><span class="keyword">val</span> lowercase_ascii : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>lowercase_ascii s</code> is <code>s</code> with all uppercase letters translated to lowercase, using the US-ASCII character set.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.03.0 (4.05.0 in StringLabels)</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-capitalize_ascii"><a href="#val-capitalize_ascii" class="anchor"></a><code><span><span class="keyword">val</span> capitalize_ascii : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>capitalize_ascii s</code> is <code>s</code> with the first character set to uppercase, using the US-ASCII character set.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.03.0 (4.05.0 in StringLabels)</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-uncapitalize_ascii"><a href="#val-uncapitalize_ascii" class="anchor"></a><code><span><span class="keyword">val</span> uncapitalize_ascii : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>uncapitalize_ascii s</code> is <code>s</code> with the first character set to lowercase, using the US-ASCII character set.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.03.0 (4.05.0 in StringLabels)</li></ul></div></div><h2 id="traversing"><a href="#traversing" class="anchor"></a>Traversing</h2><div class="odoc-spec"><div class="spec value anchored" id="val-iter"><a href="#val-iter" class="anchor"></a><code><span><span class="keyword">val</span> iter : <span><span>(<span>char <span class="arrow">&#45;&gt;</span></span> unit)</span> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>iter f s</code> applies function <code>f</code> in turn to all the characters of <code>s</code>. It is equivalent to <code>f s.[0]; f s.[1]; ...; f s.[length s - 1]; ()</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-iteri"><a href="#val-iteri" class="anchor"></a><code><span><span class="keyword">val</span> iteri : <span><span>(<span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> unit)</span> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>iteri</code> is like <a href="#val-iter"><code>iter</code></a>, but the function is also given the corresponding character index.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.00.0</li></ul></div></div><h2 id="searching"><a href="#searching" class="anchor"></a>Searching</h2><div class="odoc-spec"><div class="spec value anchored" id="val-index_from"><a href="#val-index_from" class="anchor"></a><code><span><span class="keyword">val</span> index_from : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>index_from s i c</code> is the index of the first occurrence of <code>c</code> in <code>s</code> after position <code>i</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Not_found</span> <p>if <code>c</code> does not occur in <code>s</code> after position <code>i</code>.</p></li></ul><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>i</code> is not a valid position in <code>s</code>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-index_from_opt"><a href="#val-index_from_opt" class="anchor"></a><code><span><span class="keyword">val</span> index_from_opt : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> <span>int option</span></span></code></div><div class="spec-doc"><p><code>index_from_opt s i c</code> is the index of the first occurrence of <code>c</code> in <code>s</code> after position <code>i</code> (if any).</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>i</code> is not a valid position in <code>s</code>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.05</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-rindex_from"><a href="#val-rindex_from" class="anchor"></a><code><span><span class="keyword">val</span> rindex_from : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>rindex_from s i c</code> is the index of the last occurrence of <code>c</code> in <code>s</code> before position <code>i+1</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Not_found</span> <p>if <code>c</code> does not occur in <code>s</code> before position <code>i+1</code>.</p></li></ul><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>i+1</code> is not a valid position in <code>s</code>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-rindex_from_opt"><a href="#val-rindex_from_opt" class="anchor"></a><code><span><span class="keyword">val</span> rindex_from_opt : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> <span>int option</span></span></code></div><div class="spec-doc"><p><code>rindex_from_opt s i c</code> is the index of the last occurrence of <code>c</code> in <code>s</code> before position <code>i+1</code> (if any).</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>i+1</code> is not a valid position in <code>s</code>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.05</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-index"><a href="#val-index" class="anchor"></a><code><span><span class="keyword">val</span> index : <span>string <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>index s c</code> is <a href="#val-index_from"><code>String.index_from</code></a><code> s 0 c</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-index_opt"><a href="#val-index_opt" class="anchor"></a><code><span><span class="keyword">val</span> index_opt : <span>string <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> <span>int option</span></span></code></div><div class="spec-doc"><p><code>index_opt s c</code> is <a href="#val-index_from_opt"><code>String.index_from_opt</code></a><code> s 0 c</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.05</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-rindex"><a href="#val-rindex" class="anchor"></a><code><span><span class="keyword">val</span> rindex : <span>string <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>rindex s c</code> is <a href="#val-rindex_from"><code>String.rindex_from</code></a><code> s (length s - 1) c</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-rindex_opt"><a href="#val-rindex_opt" class="anchor"></a><code><span><span class="keyword">val</span> rindex_opt : <span>string <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> <span>int option</span></span></code></div><div class="spec-doc"><p><code>rindex_opt s c</code> is <a href="#val-rindex_from_opt"><code>String.rindex_from_opt</code></a><code> s (length s - 1) c</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.05</li></ul></div></div><h2 id="strings-and-sequences"><a href="#strings-and-sequences" class="anchor"></a>Strings and Sequences</h2><div class="odoc-spec"><div class="spec value anchored" id="val-to_seq"><a href="#val-to_seq" class="anchor"></a><code><span><span class="keyword">val</span> to_seq : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>char <a href="../Seq/index.html#type-t">Seq.t</a></span></span></code></div><div class="spec-doc"><p><code>to_seq s</code> is a sequence made of the string's characters in increasing order. In <code>&quot;unsafe-string&quot;</code> mode, modifications of the string during iteration will be reflected in the sequence.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.07</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-to_seqi"><a href="#val-to_seqi" class="anchor"></a><code><span><span class="keyword">val</span> to_seqi : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><span>(int * char)</span> <a href="../Seq/index.html#type-t">Seq.t</a></span></span></code></div><div class="spec-doc"><p><code>to_seqi s</code> is like <a href="#val-to_seq"><code>to_seq</code></a> but also tuples the corresponding index.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.07</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-of_seq"><a href="#val-of_seq" class="anchor"></a><code><span><span class="keyword">val</span> of_seq : <span><span>char <a href="../Seq/index.html#type-t">Seq.t</a></span> <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>of_seq s</code> is a string made of the sequence's characters.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.07</li></ul></div></div><h2 id="utf"><a href="#utf" class="anchor"></a>UTF decoding and validations</h2><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.14</li></ul><h3 id="utf_8"><a href="#utf_8" class="anchor"></a>UTF-8</h3><div class="odoc-spec"><div class="spec value anchored" id="val-get_utf_8_uchar"><a href="#val-get_utf_8_uchar" class="anchor"></a><code><span><span class="keyword">val</span> get_utf_8_uchar : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <a href="../Uchar/index.html#type-utf_decode">Uchar.utf_decode</a></span></code></div><div class="spec-doc"><p><code>get_utf_8_uchar b i</code> decodes an UTF-8 character at index <code>i</code> in <code>b</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_valid_utf_8"><a href="#val-is_valid_utf_8" class="anchor"></a><code><span><span class="keyword">val</span> is_valid_utf_8 : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>is_valid_utf_8 b</code> is <code>true</code> if and only if <code>b</code> contains valid UTF-8 data.</p></div></div><h3 id="utf_16be"><a href="#utf_16be" class="anchor"></a>UTF-16BE</h3><div class="odoc-spec"><div class="spec value anchored" id="val-get_utf_16be_uchar"><a href="#val-get_utf_16be_uchar" class="anchor"></a><code><span><span class="keyword">val</span> get_utf_16be_uchar : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <a href="../Uchar/index.html#type-utf_decode">Uchar.utf_decode</a></span></code></div><div class="spec-doc"><p><code>get_utf_16be_uchar b i</code> decodes an UTF-16BE character at index <code>i</code> in <code>b</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_valid_utf_16be"><a href="#val-is_valid_utf_16be" class="anchor"></a><code><span><span class="keyword">val</span> is_valid_utf_16be : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>is_valid_utf_16be b</code> is <code>true</code> if and only if <code>b</code> contains valid UTF-16BE data.</p></div></div><h3 id="utf_16le"><a href="#utf_16le" class="anchor"></a>UTF-16LE</h3><div class="odoc-spec"><div class="spec value anchored" id="val-get_utf_16le_uchar"><a href="#val-get_utf_16le_uchar" class="anchor"></a><code><span><span class="keyword">val</span> get_utf_16le_uchar : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <a href="../Uchar/index.html#type-utf_decode">Uchar.utf_decode</a></span></code></div><div class="spec-doc"><p><code>get_utf_16le_uchar b i</code> decodes an UTF-16LE character at index <code>i</code> in <code>b</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_valid_utf_16le"><a href="#val-is_valid_utf_16le" class="anchor"></a><code><span><span class="keyword">val</span> is_valid_utf_16le : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>is_valid_utf_16le b</code> is <code>true</code> if and only if <code>b</code> contains valid UTF-16LE data.</p></div></div><h2 id="deprecated"><a href="#deprecated" class="anchor"></a>Deprecated functions</h2><div class="odoc-spec"><div class="spec value external anchored" id="val-create"><a href="#val-create" class="anchor"></a><code><span><span class="keyword">val</span> create : <span>int <span class="arrow">&#45;&gt;</span></span> bytes</span></code></div><div class="spec-doc"><p><code>create n</code> returns a fresh byte sequence of length <code>n</code>. The sequence is uninitialized and contains arbitrary bytes.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>n &lt; 0</code> or <code>n &gt; </code><a href="../Sys/index.html#val-max_string_length"><code>Sys.max_string_length</code></a>.</p></li></ul><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>This is a deprecated alias of <a href="../Bytes/index.html#val-create"><code>Bytes.create</code></a>/<a href="../BytesLabels/index.html#val-create"><code>BytesLabels.create</code></a>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value external anchored" id="val-set"><a href="#val-set" class="anchor"></a><code><span><span class="keyword">val</span> set : <span>bytes <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>set s n c</code> modifies byte sequence <code>s</code> in place, replacing the byte at index <code>n</code> with <code>c</code>. You can also write <code>s.[n] &lt;- c</code> instead of <code>set s n c</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>n</code> is not a valid index in <code>s</code>.</p></li></ul><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>This is a deprecated alias of <a href="../Bytes/index.html#val-set"><code>Bytes.set</code></a>/<a href="../BytesLabels/index.html#val-set"><code>BytesLabels.set</code></a>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-blit"><a href="#val-blit" class="anchor"></a><code><span><span class="keyword">val</span> blit : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>bytes <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>blit src src_pos dst dst_pos len</code> copies <code>len</code> bytes from the string <code>src</code>, starting at index <code>src_pos</code>, to byte sequence <code>dst</code>, starting at character number <code>dst_pos</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>src_pos</code> and <code>len</code> do not designate a valid range of <code>src</code>, or if <code>dst_pos</code> and <code>len</code> do not designate a valid range of <code>dst</code>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-copy"><a href="#val-copy" class="anchor"></a><code><span><span class="keyword">val</span> copy : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Return a copy of the given string.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Because strings are immutable, it doesn't make much sense to make identical copies of them.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-fill"><a href="#val-fill" class="anchor"></a><code><span><span class="keyword">val</span> fill : <span>bytes <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>fill s pos len c</code> modifies byte sequence <code>s</code> in place, replacing <code>len</code> bytes by <code>c</code>, starting at <code>pos</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if <code>pos</code> and <code>len</code> do not designate a valid substring of <code>s</code>.</p></li></ul><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>This is a deprecated alias of <a href="../Bytes/index.html#val-fill"><code>Bytes.fill</code></a>/<a href="../BytesLabels/index.html#val-fill"><code>BytesLabels.fill</code></a>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-uppercase"><a href="#val-uppercase" class="anchor"></a><code><span><span class="keyword">val</span> uppercase : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Return a copy of the argument, with all lowercase letters translated to uppercase, including accented letters of the ISO Latin-1 (8859-1) character set.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Functions operating on Latin-1 character set are deprecated.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-lowercase"><a href="#val-lowercase" class="anchor"></a><code><span><span class="keyword">val</span> lowercase : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Return a copy of the argument, with all uppercase letters translated to lowercase, including accented letters of the ISO Latin-1 (8859-1) character set.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Functions operating on Latin-1 character set are deprecated.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-capitalize"><a href="#val-capitalize" class="anchor"></a><code><span><span class="keyword">val</span> capitalize : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Return a copy of the argument, with the first character set to uppercase, using the ISO Latin-1 (8859-1) character set..</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Functions operating on Latin-1 character set are deprecated.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-uncapitalize"><a href="#val-uncapitalize" class="anchor"></a><code><span><span class="keyword">val</span> uncapitalize : <span>string <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Return a copy of the argument, with the first character set to lowercase, using the ISO Latin-1 (8859-1) character set.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Functions operating on Latin-1 character set are deprecated.</p></li></ul></div></div><h2 id="binary-decoding-of-integers"><a href="#binary-decoding-of-integers" class="anchor"></a>Binary decoding of integers</h2><p>The functions in this section binary decode integers from strings.</p><p>All following functions raise <code>Invalid_argument</code> if the characters needed at index <code>i</code> to decode the integer are not available.</p><p>Little-endian (resp. big-endian) encoding means that least (resp. most) significant bytes are stored first. Big-endian is also known as network byte order. Native-endian encoding is either little-endian or big-endian depending on <a href="../Sys/index.html#val-big_endian"><code>Sys.big_endian</code></a>.</p><p>32-bit and 64-bit integers are represented by the <code>int32</code> and <code>int64</code> types, which can be interpreted either as signed or unsigned numbers.</p><p>8-bit and 16-bit integers are represented by the <code>int</code> type, which has more bits than the binary encoding. These extra bits are sign-extended (or zero-extended) for functions which decode 8-bit or 16-bit integers and represented them with <code>int</code> values.</p><div class="odoc-spec"><div class="spec value anchored" id="val-get_uint8"><a href="#val-get_uint8" class="anchor"></a><code><span><span class="keyword">val</span> get_uint8 : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>get_uint8 b i</code> is <code>b</code>'s unsigned 8-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_int8"><a href="#val-get_int8" class="anchor"></a><code><span><span class="keyword">val</span> get_int8 : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>get_int8 b i</code> is <code>b</code>'s signed 8-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_uint16_ne"><a href="#val-get_uint16_ne" class="anchor"></a><code><span><span class="keyword">val</span> get_uint16_ne : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>get_uint16_ne b i</code> is <code>b</code>'s native-endian unsigned 16-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_uint16_be"><a href="#val-get_uint16_be" class="anchor"></a><code><span><span class="keyword">val</span> get_uint16_be : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>get_uint16_be b i</code> is <code>b</code>'s big-endian unsigned 16-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_uint16_le"><a href="#val-get_uint16_le" class="anchor"></a><code><span><span class="keyword">val</span> get_uint16_le : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>get_uint16_le b i</code> is <code>b</code>'s little-endian unsigned 16-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_int16_ne"><a href="#val-get_int16_ne" class="anchor"></a><code><span><span class="keyword">val</span> get_int16_ne : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>get_int16_ne b i</code> is <code>b</code>'s native-endian signed 16-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_int16_be"><a href="#val-get_int16_be" class="anchor"></a><code><span><span class="keyword">val</span> get_int16_be : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>get_int16_be b i</code> is <code>b</code>'s big-endian signed 16-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_int16_le"><a href="#val-get_int16_le" class="anchor"></a><code><span><span class="keyword">val</span> get_int16_le : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p><code>get_int16_le b i</code> is <code>b</code>'s little-endian signed 16-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_int32_ne"><a href="#val-get_int32_ne" class="anchor"></a><code><span><span class="keyword">val</span> get_int32_ne : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int32</span></code></div><div class="spec-doc"><p><code>get_int32_ne b i</code> is <code>b</code>'s native-endian 32-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_int32_be"><a href="#val-get_int32_be" class="anchor"></a><code><span><span class="keyword">val</span> get_int32_be : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int32</span></code></div><div class="spec-doc"><p><code>get_int32_be b i</code> is <code>b</code>'s big-endian 32-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_int32_le"><a href="#val-get_int32_le" class="anchor"></a><code><span><span class="keyword">val</span> get_int32_le : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int32</span></code></div><div class="spec-doc"><p><code>get_int32_le b i</code> is <code>b</code>'s little-endian 32-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_int64_ne"><a href="#val-get_int64_ne" class="anchor"></a><code><span><span class="keyword">val</span> get_int64_ne : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int64</span></code></div><div class="spec-doc"><p><code>get_int64_ne b i</code> is <code>b</code>'s native-endian 64-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_int64_be"><a href="#val-get_int64_be" class="anchor"></a><code><span><span class="keyword">val</span> get_int64_be : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int64</span></code></div><div class="spec-doc"><p><code>get_int64_be b i</code> is <code>b</code>'s big-endian 64-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_int64_le"><a href="#val-get_int64_le" class="anchor"></a><code><span><span class="keyword">val</span> get_int64_le : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> int64</span></code></div><div class="spec-doc"><p><code>get_int64_le b i</code> is <code>b</code>'s little-endian 64-bit integer starting at character index <code>i</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.13.0</li></ul></div></div></div></body></html>