# nemtrif/utfcpp architecture

> Architecture diagram of the GitHub repository nemtrif/utfcpp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nemtrif/utfcpp
- Repository: https://github.com/nemtrif/utfcpp

## Overview

UTF8-CPP is a header-only, generic C++ library for working with UTF-8 and UTF-16 text. A typical caller supplies text or iterators, then validates or repairs encoded input, traverses code points, or converts between UTF-8, UTF-16, and UTF-32. The checked API provides validation and error reporting; the unchecked API offers a separate unchecked path. Standard-version headers add string and view conveniences. The graph reflects the README and indexed imports; unsampled implementation details are not inferred.

Main entry points: [`source/utf8.h`](https://github.com/nemtrif/utfcpp/blob/master/source/utf8.h) (Header Facade), [`source/utf8/checked.h`](https://github.com/nemtrif/utfcpp/blob/master/source/utf8/checked.h) (Checked Operations), [`source/utf8/unchecked.h`](https://github.com/nemtrif/utfcpp/blob/master/source/utf8/unchecked.h) (Unchecked Operations), [`source/utf8/cpp11.h`](https://github.com/nemtrif/utfcpp/blob/master/source/utf8/cpp11.h) (C++11 Strings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["UTF APIs"]
  node_facade["Header Facade<br/>[utf8.h]"]
  node_checked["Checked Operations<br/>[checked.h]"]
  node_unchecked["Unchecked Operations<br/>[unchecked.h]"]
end

subgraph group_engine["Encoding Engine"]
  node_core["Decode and Validate<br/>[core.h]"]
end

subgraph group_wrappers["C++ Wrappers"]
  node_cpp11["C++11 Strings<br/>[cpp11.h]"]
  node_cpp17["C++17 Views<br/>[cpp17.h]"]
  node_cpp20["C++20 UTF-8<br/>[cpp20.h]"]
end

node_caller(("C++ Caller"))

node_caller -->|"uses"| node_facade
node_facade -->|"includes"| node_checked
node_facade -->|"includes"| node_unchecked
node_checked -->|"validates with"| node_core
node_unchecked -->|"uses internals"| node_core
node_cpp11 -->|"wraps"| node_checked
node_cpp17 -->|"extends"| node_cpp11
node_cpp20 -->|"extends"| node_cpp17

click node_facade "https://github.com/nemtrif/utfcpp/blob/master/source/utf8.h"
click node_checked "https://github.com/nemtrif/utfcpp/blob/master/source/utf8/checked.h"
click node_unchecked "https://github.com/nemtrif/utfcpp/blob/master/source/utf8/unchecked.h"
click node_core "https://github.com/nemtrif/utfcpp/blob/master/source/utf8/core.h"
click node_cpp11 "https://github.com/nemtrif/utfcpp/blob/master/source/utf8/cpp11.h"
click node_cpp17 "https://github.com/nemtrif/utfcpp/blob/master/source/utf8/cpp17.h"
click node_cpp20 "https://github.com/nemtrif/utfcpp/blob/master/source/utf8/cpp20.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_facade,node_checked,node_unchecked toneBlue
class node_core toneAmber
class node_cpp11,node_cpp17,node_cpp20 toneMint
class node_caller toneIndigo
```

## Components

### UTF APIs

- [Header Facade](https://github.com/nemtrif/utfcpp/blob/master/source/utf8.h): `source/utf8.h`
- [Checked Operations](https://github.com/nemtrif/utfcpp/blob/master/source/utf8/checked.h): `source/utf8/checked.h`
- [Unchecked Operations](https://github.com/nemtrif/utfcpp/blob/master/source/utf8/unchecked.h): `source/utf8/unchecked.h`

### Encoding Engine

- [Decode and Validate](https://github.com/nemtrif/utfcpp/blob/master/source/utf8/core.h): `source/utf8/core.h`

### C++ Wrappers

- [C++11 Strings](https://github.com/nemtrif/utfcpp/blob/master/source/utf8/cpp11.h): `source/utf8/cpp11.h`
- [C++17 Views](https://github.com/nemtrif/utfcpp/blob/master/source/utf8/cpp17.h): `source/utf8/cpp17.h`
- [C++20 UTF-8](https://github.com/nemtrif/utfcpp/blob/master/source/utf8/cpp20.h): `source/utf8/cpp20.h`

### Other components

- **C++ Caller**

## Connections

- C++ Caller → Header Facade: uses (evidence: `README.md`)
- Header Facade → Checked Operations: includes (evidence: `source/utf8.h`)
- Header Facade → Unchecked Operations: includes (evidence: `source/utf8.h`)
- Checked Operations → Decode and Validate: validates with (evidence: `source/utf8/checked.h`)
- Unchecked Operations → Decode and Validate: uses internals (evidence: `source/utf8/unchecked.h`)
- C++11 Strings → Checked Operations: wraps (evidence: `source/utf8/cpp11.h`)
- C++17 Views → C++11 Strings: extends (evidence: `source/utf8/cpp17.h`)
- C++20 UTF-8 → C++17 Views: extends (evidence: `source/utf8/cpp20.h`)
