# Names and Case

_Peios Kernel / Internals / LCS / Data model_

> Every string in the LCS interface is UTF-8 — length as byte count, separators, and how case folding works.

<a id="trm-5-2-8"></a>

Every string in the LCS interface — key names, value names, hive names,
layer names, paths — is UTF-8. Invalid UTF-8 is rejected with `EINVAL`
before parsing, routing, folding, layer resolution or source
dispatch. <a id="cite-name.utf8.invalid-utf8-is-einval-before-any-other-work"></a>

Null bytes are rejected in all of them. <a id="cite-name.utf8.null-bytes-rejected-in-every-string"></a>
The rejection is `EINVAL` where the string is length-delimited — ioctl
and RSI strings — because there the null byte sits inside the counted
length. A syscall argument (a path or `reg_create_key`'s layer name) is
a C string, and a null byte there is its terminator: the name the
kernel validates ends at it, and nothing after it is read. <a id="cite-name.utf8.syscall-strings-end-at-the-null"></a>

The one thing that is not a string is value data, which is opaque
bytes.

<a id="trm-5-2-8-1"></a>

## Lengths are byte counts

Every configured length limit is measured in UTF-8 bytes, not Unicode
scalar values and not display characters. <a id="cite-name.length.measured-in-utf8-bytes"></a>

- `MaxPathComponentLength` (default 255) bounds one component or one
  value or layer name. <a id="cite-name.length.max-path-component-length-bounds-a-component"></a>
- `MaxTotalPathLength` (default 16383) bounds a whole
  path. <a id="cite-name.length.max-total-path-length-bounds-a-path"></a>
- `MaxKeyDepth` (default 512) bounds nesting. <a id="cite-name.length.max-key-depth-bounds-nesting"></a>

A syscall path arrives as a null-terminated C string, is copied under a
hard bound, and has its terminator stripped before anything is
measured — so the terminator is not part of the
length. <a id="cite-name.length.syscall-path-terminator-is-not-counted"></a>

Ioctl and RSI strings are length-delimited and need no terminator; a
terminator byte included in the length is a null byte and is therefore
invalid. <a id="cite-name.length.ioctl-and-rsi-strings-are-length-delimited"></a>

<a id="trm-5-2-8-2"></a>

## Separators

Backslash is canonical. Forward slash is accepted on input and treated
as a separator wherever a separator is recognised, so a component can
never contain either. <a id="cite-name.separator.forward-slash-is-a-separator"></a>

There is no string-rewriting step: normalisation is a property of how
paths are split rather than a transformation applied to
them. <a id="cite-name.separator.no-string-rewriting-step"></a>

<a id="trm-5-2-8-3"></a>

## Case folding

Comparison is case-insensitive and storage is
case-preserving. <a id="cite-name.case.insensitive-comparison-preserving-storage"></a>

The algorithm is **Unicode Simple Case Folding** — the `C` and `S`
status entries of `CaseFolding.txt`, with the full (`F`) and Turkic
(`T`) entries excluded. <a id="cite-name.case.simple-case-folding-c-and-s-entries-only"></a>

It is a fixed one-to-one codepoint mapping with no locale input,
applied after decoding from UTF-8, never to raw
bytes. <a id="cite-name.case.folding-applied-to-codepoints-not-bytes"></a>

The Unicode version is **pinned at 16.0**. <a id="cite-name.case.unicode-version-pinned-at-16-0"></a> The table is generated by
`peios/generate-casefold-table.py` and checked in with the
digest of the source data, so adopting a newer Unicode version means
regenerating the table deliberately. It is not something that happens
by updating a dependency.

This gives practical compatibility with Windows'
`RtlCompareUnicodeString` without claiming byte-identical behaviour in
every edge case.

**Unicode normalisation is not performed.** NFC and NFD forms of the
same visual character are different names, matching
Windows. <a id="cite-name.case.no-unicode-normalisation"></a>

Case folding is what "identity" means throughout: a layer's identity is
its folded name, a hive route's identity includes its folded name, and
a duplicate is a folded-equal duplicate. `RoleA` and `rolea` are one
layer, not two. <a id="cite-name.case.identity-is-the-folded-name"></a>

Every comparison folds, on both sides of the kernel boundary. The
Kernel Access Control Subsystem (KACS) parses private layer names into
a token and rejects a duplicate with `EINVAL`; that duplicate check
uses the same folding routine and the same table as LCS, so a pair
that LCS treats as one layer cannot occupy two of a token's slots.
There were two ASCII-only comparators, the `base` check on two of its
call sites and this KACS check, and both are gone ([The Base Layer](</kernel/internals/lcs/layers/the-base-layer.md#trm-5-3-2>) for
`base`). <a id="cite-name.case.every-comparison-folds"></a>
