# The Incredible Unicode Mess

**URL:** <https://ziggit.dev/t/the-incredible-unicode-mess/6776>\
**Category:** Brainstorming\
**Tags:** standard-library\
**Created:** [November 9, 2024, 1:57pm UTC](https://ziggit.dev/t/the-incredible-unicode-mess/6776 "2024-11-09T13:57:27Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![squeek502](https://ziggit.dev/user_avatar/ziggit.dev/squeek502/32/409_2.png) [@squeek502](https://ziggit.dev/u/squeek502)\
**Post date:** [November 9, 2024, 2:21pm UTC](https://ziggit.dev/t/the-incredible-unicode-mess/6776/2 "2024-11-09T14:21:21Z")

</div>

Some relevant links to posts I’ve made:

> [@Why no builtin string type?](https://ziggit.dev/t/why-no-builtin-string-type/5326/2):
>
> Because strings are complicated. That zig-string library you linked, for example, would mishandle comparison: var myString = String.init(allocator); defer myString.deinit(); try myString.concat("Ç"); assert(myString.cmp("Ç")); This assertion would fail, even though the strings appear to be identical. That’s because the first uses [Normalization Form D](https://www.unicode.org/reports/tr15/): C ([U+0043](https://www.compart.com/en/unicode/U+0043)) + ◌̧ ([U+0327](https://www.compart.com/en/unicode/U+0327)), while the second uses Normalization Form C: Ç ([U+00C7](https://www.compart.com/en/unicode/U+00C7)). To actually compare UTF-8 strings in ways a human might exp…

(also see the other responses in that thread)

> [@Zig’s lack of a string type & invalid values](https://ziggit.dev/t/zig-s-lack-of-a-string-type-invalid-values/5425/12):
>
> I don’t think this is the correct way to look at it. Instead, I’d say string literals in Zig are arbitrary sequences of bytes, and Zig makes it convenient to create UTF-8 encoded string literals. For example, take [@embedFile](https://ziglang.org/documentation/master/#embedFile): @embedFile(comptime path: []const u8) \*const [N:0]u8 This function returns a compile time constant pointer to null-terminated, fixed-size array with length equal to the byte count of the file given by path. The contents of the array are the contents of the file. This i…

Quoting from the first link:

> This series of articles by @dude_the_builder details the complication of Unicode well:
> 
> - [Unicode Basics in Zig - Zig NEWS](https://zig.news/dude_the_builder/unicode-basics-in-zig-dj3)
> - [Ziglyph Unicode Wrangling - Zig NEWS](https://zig.news/dude_the_builder/ziglyph-unicode-wrangling-llj)
> - [Unicode String Operations - Zig NEWS](https://zig.news/dude_the_builder/unicode-string-operations-536e)
> 
> (note that ziglyph has now been superseded by [zg](https://codeberg.org/dude_the_builder/zg))

---

_[View the full topic](https://ziggit.dev/t/the-incredible-unicode-mess/6776)._
