ludic/uuid-parse.html
2026-09-17 22:10:03 +00:00

34 lines
No EOL
2.5 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 lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Uuid.parse — Ludic</title>
<meta name="description" content="Normalise an untrusted string to a lowercase UUID, or the nil UUID.">
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="docs.css">
</head>
<body>
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
<main class="wrap item">
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-uuid.html">Uuid</a> <span>›</span> <span class="here">Uuid.parse</span></div>
<div class="item-head">
<span class="kind-badge kind-method">method</span>
<h1 id="top">Uuid.parse</h1>
</div>
<code class="sig">Uuid.parse(s) -&gt; string</code>
<div class="desc"><p>Normalises an untrusted string: if <code>s</code> is a well-formed UUID it returns the same value in canonical lowercase form; if it is not, it returns the <a href="uuid-nil"><code>nil</code></a> UUID. This never faults on garbage, so it is safe to call on data that arrived from a file, a network peer, or a mod. When you need to *reject* bad input rather than fold it to nil, gate on <a href="uuid-is_valid"><code>Uuid.is_valid</code></a> first.</p><p>Parsing accepts either case and yields the lowercase canonical form, which is what the rest of the library produces — so a parsed ID compares equal (with <code>==</code>) to a freshly generated one of the same value.</p></div>
<div class="params"><h2>Parameters</h2><div class="param" id="param-s"><code class="pname">s</code><span class="pdesc">the string to validate and normalise</span></div></div>
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Parse {
entry {
let id = Uuid.parse("550E8400-E29B-41D4-A716-446655440000")
print(id[0..8]) # 550e8400 — lowercased
if Uuid.parse("nope") == Uuid.nil() { print(1) }
}
}</pre></div>
<a class="back" href="api.html">← All symbols</a>
</main>
<script src="ludic-highlight.js"></script>
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
</body></html>