tiny_httpd/ocaml/Misc/Utf8_lexeme/index.html
2025-03-21 12:40:14 +00:00

2 lines
6.9 KiB
HTML
Raw Permalink 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>Utf8_lexeme (ocaml.Misc.Utf8_lexeme)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.0.0"/><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">Index</a> &#x00BB; <a href="../../index.html">ocaml</a> &#x00BB; <a href="../index.html">Misc</a> &#x00BB; Utf8_lexeme</nav><header class="odoc-preamble"><h1>Module <code><span>Misc.Utf8_lexeme</span></code></h1></header><div class="odoc-content"><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><div class="odoc-spec"><div class="spec value anchored" id="val-normalize"><a href="#val-normalize" class="anchor"></a><code><span><span class="keyword">val</span> normalize : <span>string <span class="arrow">&#45;&gt;</span></span> <span><span>(<a href="#type-t">t</a>, <a href="#type-t">t</a>)</span> <a href="../../Stdlib/Result/index.html#type-t">Stdlib.Result.t</a></span></span></code></div><div class="spec-doc"><p>Normalize the given UTF-8 encoded string. Invalid UTF-8 sequences results in a error and are replaced by U+FFFD. Identifier characters are put in NFC normalized form. Other Unicode characters are left unchanged.</p></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> <span><span>(<a href="#type-t">t</a>, <a href="#type-t">t</a>)</span> <a href="../../Stdlib/Result/index.html#type-t">Stdlib.Result.t</a></span></span></code></div><div class="spec-doc"><p>Like <code>normalize</code>, but if the string starts with a lowercase identifier character, it is replaced by the corresponding uppercase character. Subsequent characters are not changed.</p></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> <span><span>(<a href="#type-t">t</a>, <a href="#type-t">t</a>)</span> <a href="../../Stdlib/Result/index.html#type-t">Stdlib.Result.t</a></span></span></code></div><div class="spec-doc"><p>Like <code>normalize</code>, but if the string starts with an uppercase identifier character, it is replaced by the corresponding lowercase character. Subsequent characters are not changed.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_capitalized"><a href="#val-is_capitalized" class="anchor"></a><code><span><span class="keyword">val</span> is_capitalized : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p>Returns <code>true</code> if the given normalized string starts with an uppercase identifier character, <code>false</code> otherwise. May return wrong results if the string is not normalized.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_valid_identifier"><a href="#val-is_valid_identifier" class="anchor"></a><code><span><span class="keyword">val</span> is_valid_identifier : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p>Check whether the given normalized string is a valid OCaml identifier:</p><ul><li>all characters are identifier characters</li><li>it does not start with a digit or a single quote</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_lowercase"><a href="#val-is_lowercase" class="anchor"></a><code><span><span class="keyword">val</span> is_lowercase : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p>Returns <code>true</code> if the given normalized string only contains lowercase identifier character, <code>false</code> otherwise. May return wrong results if the string is not normalized.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-validation_result"><a href="#type-validation_result" class="anchor"></a><code><span><span class="keyword">type</span> validation_result</span><span> = </span></code><ol><li id="type-validation_result.Valid" class="def variant constructor anchored"><a href="#type-validation_result.Valid" class="anchor"></a><code><span>| </span><span><span class="constructor">Valid</span></span></code></li><li id="type-validation_result.Invalid_character" class="def variant constructor anchored"><a href="#type-validation_result.Invalid_character" class="anchor"></a><code><span>| </span><span><span class="constructor">Invalid_character</span> <span class="keyword">of</span> <a href="../../Stdlib/Uchar/index.html#type-t">Stdlib.Uchar.t</a></span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Character not allowed</p><span class="comment-delim">*)</span></div></li><li id="type-validation_result.Invalid_beginning" class="def variant constructor anchored"><a href="#type-validation_result.Invalid_beginning" class="anchor"></a><code><span>| </span><span><span class="constructor">Invalid_beginning</span> <span class="keyword">of</span> <a href="../../Stdlib/Uchar/index.html#type-t">Stdlib.Uchar.t</a></span></code><div class="def-doc"><span class="comment-delim">(*</span><p>Character not allowed as first char</p><span class="comment-delim">*)</span></div></li></ol></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-validate_identifier"><a href="#val-validate_identifier" class="anchor"></a><code><span><span class="keyword">val</span> validate_identifier : <span><span class="optlabel">?with_dot</span>:bool <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-validation_result">validation_result</a></span></code></div><div class="spec-doc"><p>Like <code>is_valid_identifier</code>, but returns a more detailed error code. Dots can be allowed to extend support to path-like identifiers.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-starts_like_a_valid_identifier"><a href="#val-starts_like_a_valid_identifier" class="anchor"></a><code><span><span class="keyword">val</span> starts_like_a_valid_identifier : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p>Checks whether the given normalized string starts with an identifier character other than a digit or a single quote. Subsequent characters are not checked.</p></div></div></div></body></html>