<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="next" href="Zed_rope.html"> <link rel="Up" href="index.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="Zed_utf8" rel="Chapter" href="Zed_utf8.html"> <link title="Zed_rope" rel="Chapter" href="Zed_rope.html"> <link title="Zed_edit" rel="Chapter" href="Zed_edit.html"> <link title="Zed_cursor" rel="Chapter" href="Zed_cursor.html"> <link title="Zed_lines" rel="Chapter" href="Zed_lines.html"> <link title="Zed_re" rel="Chapter" href="Zed_re.html"> <link title="Zed_input" rel="Chapter" href="Zed_input.html"> <link title="Zed_macro" rel="Chapter" href="Zed_macro.html"><link title="Validation" rel="Section" href="#6_Validation"> <link title="Construction" rel="Section" href="#6_Construction"> <link title="Informations" rel="Section" href="#6_Informations"> <link title="Comparison" rel="Section" href="#6_Comparison"> <link title="Random access" rel="Section" href="#6_Randomaccess"> <link title="String manipulation" rel="Section" href="#6_Stringmanipulation"> <link title="Tranformation" rel="Section" href="#6_Tranformation"> <link title="Text traversals" rel="Section" href="#6_Texttraversals"> <link title="Scanning" rel="Section" href="#6_Scanning"> <link title="Tests" rel="Section" href="#6_Tests"> <link title="Stripping" rel="Section" href="#6_Stripping"> <link title="Buffers" rel="Section" href="#6_Buffers"> <link title="Escaping" rel="Section" href="#6_Escaping"> <link title="Safe offset API" rel="Section" href="#6_SafeoffsetAPI"> <link title="Unsafe offset API" rel="Section" href="#6_UnsafeoffsetAPI"> <title>Zed_utf8</title> </head> <body> <div class="navbar"> <a class="up" href="index.html" title="Index">Up</a> <a class="post" href="Zed_rope.html" title="Zed_rope">Next</a> </div> <h1>Module <a href="type_Zed_utf8.html">Zed_utf8</a></h1> <pre><span class="keyword">module</span> Zed_utf8: <code class="code">sig</code> <a href="Zed_utf8.html">..</a> <code class="code">end</code></pre><div class="info module top"> UTF-8 enoded strings<br> </div> <hr width="100%"> <pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> = <code class="type">string</code> </pre> <div class="info "> Type of UTF-8 encoded strings.<br> </div> <pre><span id="EXCEPTIONInvalid"><span class="keyword">exception</span> Invalid</span> <span class="keyword">of</span> <code class="type">string * string</code></pre> <div class="info "> <code class="code">Invalid(error, text)</code> Exception raised when an invalid UTF-8 encoded string is encountered. <code class="code">text</code> is the faulty text and <code class="code">error</code> is a description of the first error in <code class="code">text</code>.<br> </div> <pre><span id="EXCEPTIONOut_of_bounds"><span class="keyword">exception</span> Out_of_bounds</span></pre> <div class="info "> Exception raised when trying to access a character which is outside the bounds of a string.<br> </div> <br> <h6 id="6_Validation">Validation</h6><br> <pre><code><span id="TYPEcheck_result"><span class="keyword">type</span> <code class="type"></code>check_result</span> = </code></pre><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTcheck_result.Correct"><span class="constructor">Correct</span></span> <span class="keyword">of</span> <code class="type">int</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The string is correctly UTF-8 encoded, and the paramter is the length of the string.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTcheck_result.Message"><span class="constructor">Message</span></span> <span class="keyword">of</span> <code class="type">string</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The string is invalid and the parameter is an error message.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> <div class="info "> Result of cheking a string for correct UTF-8.<br> </div> <pre><span id="VALcheck"><span class="keyword">val</span> check</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEcheck_result">check_result</a></code></pre><div class="info "> <code class="code">check str</code> checks that <code class="code">str</code> is a valid UTF-8 encoded string.<br> </div> <pre><span id="VALvalidate"><span class="keyword">val</span> validate</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int</code></pre><div class="info "> Same as check but raises an exception in case the argument is not a valid text, otherwise returns the length of the string.<br> </div> <pre><span id="VALnext_error"><span class="keyword">val</span> next_error</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> int * int * string</code></pre><div class="info "> <code class="code">next_error str ofs</code> returns <code class="code">(ofs', count, msg)</code> where <code class="code">ofs'</code> is the offset of the start of the first invalid sequence after <code class="code">ofs</code> (inclusive) in <code class="code">str</code>, <code class="code">count</code> is the number of unicode character between <code class="code">ofs</code> and <code class="code">ofs'</code> (exclusive) and <code class="code">msg</code> is an error message. If there is no error until the end of string then <code class="code">ofs</code> is <code class="code">String.length str</code> and <code class="code">msg</code> is the empty string.<br> </div> <br> <h6 id="6_Construction">Construction</h6><br> <pre><span id="VALsingleton"><span class="keyword">val</span> singleton</span> : <code class="type">CamomileLibrary.UChar.t -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">singleton ch</code> creates a string of length 1 containing only the given character.<br> </div> <pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type">int -> CamomileLibrary.UChar.t -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">make n ch</code> creates a string of length <code class="code">n</code> filled with <code class="code">ch</code>.<br> </div> <pre><span id="VALinit"><span class="keyword">val</span> init</span> : <code class="type">int -> (int -> CamomileLibrary.UChar.t) -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">init n f</code> returns the contenation of <code class="code">singleton (f 0)</code>, <code class="code">singleton (f 1)</code>, ..., <code class="code">singleton (f (n - 1))</code>.<br> </div> <pre><span id="VALrev_init"><span class="keyword">val</span> rev_init</span> : <code class="type">int -> (int -> CamomileLibrary.UChar.t) -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rev_init n f</code> returns the contenation of <code class="code">singleton (f (n - 1))</code>, ..., <code class="code">singleton (f 1)</code>, <code class="code">singleton (f 0)</code>.<br> </div> <br> <h6 id="6_Informations">Informations</h6><br> <pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int</code></pre><div class="info "> Returns the length of the given string.<br> </div> <br> <h6 id="6_Comparison">Comparison</h6><br> <pre><span id="VALcompare"><span class="keyword">val</span> compare</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a> -> int</code></pre><div class="info "> Compares two strings (in code point order).<br> </div> <br> <h6 id="6_Randomaccess">Random access</h6><br> <pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> CamomileLibrary.UChar.t</code></pre><div class="info "> <code class="code">get str idx</code> returns the character at index <code class="code">idx</code> in <code class="code">str</code>.<br> </div> <br> <h6 id="6_Stringmanipulation">String manipulation</h6><br> <pre><span id="VALsub"><span class="keyword">val</span> sub</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> int -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">sub str ofs len</code> Returns the sub-string of <code class="code">str</code> starting at <code class="code">ofs</code> and of length <code class="code">len</code>.<br> </div> <pre><span id="VALbreak"><span class="keyword">val</span> break</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> <a href="Zed_utf8.html#TYPEt">t</a> * <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">break str pos</code> returns the sub-strings before and after <code class="code">pos</code> in <code class="code">str</code>. It is more efficient than creating two sub-strings with <a href="Zed_utf8.html#VALsub"><code class="code">Zed_utf8.sub</code></a>.<br> </div> <pre><span id="VALbefore"><span class="keyword">val</span> before</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">before str pos</code> returns the sub-string before <code class="code">pos</code> in <code class="code">str</code><br> </div> <pre><span id="VALafter"><span class="keyword">val</span> after</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">after str pos</code> returns the sub-string after <code class="code">pos</code> in <code class="code">str</code><br> </div> <pre><span id="VALinsert"><span class="keyword">val</span> insert</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">insert str pos sub</code> inserts <code class="code">sub</code> in <code class="code">str</code> at position <code class="code">pos</code>.<br> </div> <pre><span id="VALremove"><span class="keyword">val</span> remove</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> int -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">remove str pos len</code> removes the <code class="code">len</code> characters at position <code class="code">pos</code> in <code class="code">str</code><br> </div> <pre><span id="VALreplace"><span class="keyword">val</span> replace</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> int -> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">replace str pos len repl</code> replaces the <code class="code">len</code> characters at position <code class="code">pos</code> in <code class="code">str</code> by <code class="code">repl</code>.<br> </div> <br> <h6 id="6_Tranformation">Tranformation</h6><br> <pre><span id="VALrev"><span class="keyword">val</span> rev</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rev str</code> reverses all characters of <code class="code">str</code>.<br> </div> <pre><span id="VALconcat"><span class="keyword">val</span> concat</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a> list -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">concat sep l</code> returns the concatenation of all strings of <code class="code">l</code> separated by <code class="code">sep</code>.<br> </div> <pre><span id="VALrev_concat"><span class="keyword">val</span> rev_concat</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a> list -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">concat sep l</code> returns the concatenation of all strings of <code class="code">l</code> in reverse order separated by <code class="code">sep</code>.<br> </div> <pre><span id="VALexplode"><span class="keyword">val</span> explode</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> CamomileLibrary.UChar.t list</code></pre><div class="info "> <code class="code">explode str</code> returns the list of all characters of <code class="code">str</code>.<br> </div> <pre><span id="VALrev_explode"><span class="keyword">val</span> rev_explode</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> CamomileLibrary.UChar.t list</code></pre><div class="info "> <code class="code">rev_explode str</code> returns the list of all characters of <code class="code">str</code> in reverse order.<br> </div> <pre><span id="VALimplode"><span class="keyword">val</span> implode</span> : <code class="type">CamomileLibrary.UChar.t list -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">implode l</code> returns the concatenation of all characters of <code class="code">l</code>.<br> </div> <pre><span id="VALrev_implode"><span class="keyword">val</span> rev_implode</span> : <code class="type">CamomileLibrary.UChar.t list -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rev_implode l</code> is the same as <code class="code">implode (List.rev l)</code> but more efficient.<br> </div> <br> <h6 id="6_Texttraversals">Text traversals</h6><br> <pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">(CamomileLibrary.UChar.t -> unit) -> <a href="Zed_utf8.html#TYPEt">t</a> -> unit</code></pre><div class="info "> <code class="code">iter f str</code> applies <code class="code">f</code> an all characters of <code class="code">str</code> starting from the left.<br> </div> <pre><span id="VALrev_iter"><span class="keyword">val</span> rev_iter</span> : <code class="type">(CamomileLibrary.UChar.t -> unit) -> <a href="Zed_utf8.html#TYPEt">t</a> -> unit</code></pre><div class="info "> <code class="code">rev_iter f str</code> applies <code class="code">f</code> an all characters of <code class="code">str</code> starting from the right.<br> </div> <pre><span id="VALfold"><span class="keyword">val</span> fold</span> : <code class="type">(CamomileLibrary.UChar.t -> 'a -> 'a) -> <a href="Zed_utf8.html#TYPEt">t</a> -> 'a -> 'a</code></pre><div class="info "> <code class="code">fold f str acc</code> applies <code class="code">f</code> on all characters of <code class="code">str</code> starting from the left, accumulating a value.<br> </div> <pre><span id="VALrev_fold"><span class="keyword">val</span> rev_fold</span> : <code class="type">(CamomileLibrary.UChar.t -> 'a -> 'a) -> <a href="Zed_utf8.html#TYPEt">t</a> -> 'a -> 'a</code></pre><div class="info "> <code class="code">rev_fold f str acc</code> applies <code class="code">f</code> on all characters of <code class="code">str</code> starting from the right, accumulating a value.<br> </div> <pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">(CamomileLibrary.UChar.t -> CamomileLibrary.UChar.t) -><br> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">map f str</code> maps all characters of <code class="code">str</code> with <code class="code">f</code>.<br> </div> <pre><span id="VALrev_map"><span class="keyword">val</span> rev_map</span> : <code class="type">(CamomileLibrary.UChar.t -> CamomileLibrary.UChar.t) -><br> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rev_map f str</code> maps all characters of <code class="code">str</code> with <code class="code">f</code> in reverse order.<br> </div> <pre><span id="VALmap_concat"><span class="keyword">val</span> map_concat</span> : <code class="type">(CamomileLibrary.UChar.t -> <a href="Zed_utf8.html#TYPEt">t</a>) -> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">map f str</code> maps all characters of <code class="code">str</code> with <code class="code">f</code> and concatenate the result.<br> </div> <pre><span id="VALrev_map_concat"><span class="keyword">val</span> rev_map_concat</span> : <code class="type">(CamomileLibrary.UChar.t -> <a href="Zed_utf8.html#TYPEt">t</a>) -> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rev_map f str</code> maps all characters of <code class="code">str</code> with <code class="code">f</code> in reverse order and concatenate the result.<br> </div> <pre><span id="VALfilter"><span class="keyword">val</span> filter</span> : <code class="type">(CamomileLibrary.UChar.t -> bool) -> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">filter f str</code> filters characters of <code class="code">str</code> with <code class="code">f</code>.<br> </div> <pre><span id="VALrev_filter"><span class="keyword">val</span> rev_filter</span> : <code class="type">(CamomileLibrary.UChar.t -> bool) -> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rev_filter f str</code> filters characters of <code class="code">str</code> with <code class="code">f</code> in reverse order.<br> </div> <pre><span id="VALfilter_map"><span class="keyword">val</span> filter_map</span> : <code class="type">(CamomileLibrary.UChar.t -> CamomileLibrary.UChar.t option) -><br> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">filter_map f str</code> filters and maps characters of <code class="code">str</code> with <code class="code">f</code>.<br> </div> <pre><span id="VALrev_filter_map"><span class="keyword">val</span> rev_filter_map</span> : <code class="type">(CamomileLibrary.UChar.t -> CamomileLibrary.UChar.t option) -><br> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rev_filter_map f str</code> filters and maps characters of <code class="code">str</code> with <code class="code">f</code> in reverse order.<br> </div> <pre><span id="VALfilter_map_concat"><span class="keyword">val</span> filter_map_concat</span> : <code class="type">(CamomileLibrary.UChar.t -> <a href="Zed_utf8.html#TYPEt">t</a> option) -> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">filter_map f str</code> filters and maps characters of <code class="code">str</code> with <code class="code">f</code> and concatenate the result.<br> </div> <pre><span id="VALrev_filter_map_concat"><span class="keyword">val</span> rev_filter_map_concat</span> : <code class="type">(CamomileLibrary.UChar.t -> <a href="Zed_utf8.html#TYPEt">t</a> option) -> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rev_filter_map f str</code> filters and maps characters of <code class="code">str</code> with <code class="code">f</code> in reverse order and concatenate the result.<br> </div> <br> <h6 id="6_Scanning">Scanning</h6><br> <pre><span id="VALfor_all"><span class="keyword">val</span> for_all</span> : <code class="type">(CamomileLibrary.UChar.t -> bool) -> <a href="Zed_utf8.html#TYPEt">t</a> -> bool</code></pre><div class="info "> <code class="code">for_all f text</code> returns whether all characters of <code class="code">text</code> verify the predicate <code class="code">f</code>.<br> </div> <pre><span id="VALexists"><span class="keyword">val</span> exists</span> : <code class="type">(CamomileLibrary.UChar.t -> bool) -> <a href="Zed_utf8.html#TYPEt">t</a> -> bool</code></pre><div class="info "> <code class="code">exists f text</code> returns whether at least one character of <code class="code">text</code> verify <code class="code">f</code>.<br> </div> <pre><span id="VALcount"><span class="keyword">val</span> count</span> : <code class="type">(CamomileLibrary.UChar.t -> bool) -> <a href="Zed_utf8.html#TYPEt">t</a> -> int</code></pre><div class="info "> <code class="code">count f text</code> returhs the number of characters of <code class="code">text</code> verifying <code class="code">f</code>.<br> </div> <br> <h6 id="6_Tests">Tests</h6><br> <pre><span id="VALcontains"><span class="keyword">val</span> contains</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a> -> bool</code></pre><div class="info "> <code class="code">contains text sub</code> returns whether <code class="code">sub</code> appears in <code class="code">text</code><br> </div> <pre><span id="VALstarts_with"><span class="keyword">val</span> starts_with</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a> -> bool</code></pre><div class="info "> <code class="code">starts_with text prefix</code> returns <code class="code">true</code> iff <code class="code">s</code> starts with <code class="code">prefix</code>.<br> </div> <pre><span id="VALends_with"><span class="keyword">val</span> ends_with</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a> -> bool</code></pre><div class="info "> <code class="code">ends_with text suffix</code> returns <code class="code">true</code> iff <code class="code">s</code> ends with <code class="code">suffix</code>.<br> </div> <br> <h6 id="6_Stripping">Stripping</h6><br> <pre><span id="VALstrip"><span class="keyword">val</span> strip</span> : <code class="type">?predicate:(CamomileLibrary.UChar.t -> bool) -> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">strip ?predicate text</code> returns <code class="code">text</code> without its firsts and lasts characters that match <code class="code">predicate</code>. <code class="code">predicate</code> default to testing whether the given character has the <code class="code">`White_Space</code> unicode property. For example: <p> <pre class="codepre"><code class="code"> strip "\n foo\n " = "foo" </code></pre><br> </div> <pre><span id="VALlstrip"><span class="keyword">val</span> lstrip</span> : <code class="type">?predicate:(CamomileLibrary.UChar.t -> bool) -> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">lstrip ?predicate text</code> is the same as <a href="Zed_utf8.html#VALstrip"><code class="code">Zed_utf8.strip</code></a> but it only removes characters at the left of <code class="code">text</code>.<br> </div> <pre><span id="VALrstrip"><span class="keyword">val</span> rstrip</span> : <code class="type">?predicate:(CamomileLibrary.UChar.t -> bool) -> <a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">lstrip ?predicate text</code> is the same as <a href="Zed_utf8.html#VALstrip"><code class="code">Zed_utf8.strip</code></a> but it only removes characters at the right of <code class="code">text</code>.<br> </div> <pre><span id="VALlchop"><span class="keyword">val</span> lchop</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">lchop t</code> returns <code class="code">t</code> without is first character. Returns <code class="code">""</code> if <code class="code">t = ""</code><br> </div> <pre><span id="VALrchop"><span class="keyword">val</span> rchop</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rchop t</code> returns <code class="code">t</code> without is last character. Returns <code class="code">""</code> if <code class="code">t = ""</code>.<br> </div> <br> <h6 id="6_Buffers">Buffers</h6><br> <pre><span id="VALadd"><span class="keyword">val</span> add</span> : <code class="type">Buffer.t -> CamomileLibrary.UChar.t -> unit</code></pre><div class="info "> <code class="code">add buf ch</code> is the same as <code class="code">Buffer.add_string buf (singleton ch)</code> but is more efficient.<br> </div> <br> <h6 id="6_Escaping">Escaping</h6><br> <pre><span id="VALescaped_char"><span class="keyword">val</span> escaped_char</span> : <code class="type">CamomileLibrary.UChar.t -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">escaped_char ch</code> returns a string containg <code class="code">ch</code> or an escaped version of <code class="code">ch</code> if:<ul> <li><code class="code">ch</code> is a control character (code < 32)</li> <li><code class="code">ch</code> is the character with code 127</li> <li><code class="code">ch</code> is a non-ascii, non-alphabetic character</li> </ul> It uses the syntax <code class="code">\xXX</code>, <code class="code">\uXXXX</code>, <code class="code">\UXXXXXX</code> or a specific escape sequence <code class="code">\n, \r, ...</code>.<br> </div> <pre><span id="VALadd_escaped_char"><span class="keyword">val</span> add_escaped_char</span> : <code class="type">Buffer.t -> CamomileLibrary.UChar.t -> unit</code></pre><div class="info "> <code class="code">add_escaped_char buf ch</code> is the same as <code class="code">Buffer.add_string buf (escaped_char ch)</code> but a bit more efficient.<br> </div> <pre><span id="VALescaped"><span class="keyword">val</span> escaped</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">escaped text</code> escape all characters of <code class="code">text</code> as with <code class="code">escape_char</code>.<br> </div> <pre><span id="VALadd_escaped"><span class="keyword">val</span> add_escaped</span> : <code class="type">Buffer.t -> <a href="Zed_utf8.html#TYPEt">t</a> -> unit</code></pre><div class="info "> <code class="code">add_escaped_char buf text</code> is the same as <code class="code">Buffer.add_string buf (escaped text)</code> but a bit more efficient.<br> </div> <pre><span id="VALescaped_string"><span class="keyword">val</span> escaped_string</span> : <code class="type">CamomileLibraryDyn.Camomile.CharEncoding.t -> string -> <a href="Zed_utf8.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">escaped_string enc str</code> escape the string <code class="code">str</code> which is encoded with encoding <code class="code">enc</code>. If decoding <code class="code">str</code> with <code class="code">enc</code> fails, it escape all non-printable bytes of <code class="code">str</code> with the syntax <code class="code">\yAB</code>.<br> </div> <pre><span id="VALadd_escaped_string"><span class="keyword">val</span> add_escaped_string</span> : <code class="type">Buffer.t -> CamomileLibraryDyn.Camomile.CharEncoding.t -> string -> unit</code></pre><div class="info "> <code class="code">add_escaped_char buf enc text</code> is the same as <code class="code">Buffer.add_string buf (escaped_string enc text)</code> but a bit more efficient.<br> </div> <br> <h6 id="6_SafeoffsetAPI">Safe offset API</h6><br> <pre><span id="VALnext"><span class="keyword">val</span> next</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> int</code></pre><div class="info "> <code class="code">next str ofs</code> returns the offset of the next character in <code class="code">str</code>.<br> </div> <pre><span id="VALprev"><span class="keyword">val</span> prev</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> int</code></pre><div class="info "> <code class="code">prev str ofs</code> returns the offset of the previous character in <code class="code">str</code>.<br> </div> <pre><span id="VALextract"><span class="keyword">val</span> extract</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> CamomileLibrary.UChar.t</code></pre><div class="info "> <code class="code">extract str ofs</code> returns the code-point at offset <code class="code">ofs</code> in <code class="code">str</code>.<br> </div> <pre><span id="VALextract_next"><span class="keyword">val</span> extract_next</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> CamomileLibrary.UChar.t * int</code></pre><div class="info "> <code class="code">extract_next str ofs</code> returns the code-point at offset <code class="code">ofs</code> in <code class="code">str</code> and the offset the next character.<br> </div> <pre><span id="VALextract_prev"><span class="keyword">val</span> extract_prev</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> CamomileLibrary.UChar.t * int</code></pre><div class="info "> <code class="code">extract_prev str ofs</code> returns the code-point at the previous offset in <code class="code">str</code> and this offset.<br> </div> <br> <h6 id="6_UnsafeoffsetAPI">Unsafe offset API</h6><br> <br> These functions does not check that the given offset is inside the bounds of the given string.<br> <pre><span id="VALunsafe_next"><span class="keyword">val</span> unsafe_next</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> int</code></pre><div class="info "> <code class="code">unsafe_next str ofs</code> returns the offset of the next character in <code class="code">str</code>.<br> </div> <pre><span id="VALunsafe_prev"><span class="keyword">val</span> unsafe_prev</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> int</code></pre><div class="info "> <code class="code">unsafe_prev str ofs</code> returns the offset of the previous character in <code class="code">str</code>.<br> </div> <pre><span id="VALunsafe_extract"><span class="keyword">val</span> unsafe_extract</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> CamomileLibrary.UChar.t</code></pre><div class="info "> <code class="code">unsafe_extract str ofs</code> returns the code-point at offset <code class="code">ofs</code> in <code class="code">str</code>.<br> </div> <pre><span id="VALunsafe_extract_next"><span class="keyword">val</span> unsafe_extract_next</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> CamomileLibrary.UChar.t * int</code></pre><div class="info "> <code class="code">unsafe_extract_next str ofs</code> returns the code-point at offset <code class="code">ofs</code> in <code class="code">str</code> and the offset the next character.<br> </div> <pre><span id="VALunsafe_extract_prev"><span class="keyword">val</span> unsafe_extract_prev</span> : <code class="type"><a href="Zed_utf8.html#TYPEt">t</a> -> int -> CamomileLibrary.UChar.t * int</code></pre><div class="info "> <code class="code">unsafe_extract_prev str ofs</code> returns the code-point at the previous offset in <code class="code">str</code> and this offset.<br> </div> </body></html>