llvm-project
6bd1cb3c - [libc] Add UTF-16 support in CharacterConverter [1/6] (#230434)

Commit
8 hours ago
[libc] Add UTF-16 support in CharacterConverter [1/6] (#230434) This pull request adds support of UTF-16 in `CharacterConverter`. It does not use the functionality yet. Follow-ups will add uses to the functionality that this PR implements. Aside from `push(char16_t)` and `pop_utf16()` that implements the conversion, another function `isPartiallyPopping()` is added, which distinguishes if the current state is "partially pushing" or "partially popping". Since UTF-16 can have 2 code units for 1 code point, this reporting function will be crucial to the follow-up uses. For `isPartiallyPopping()` to work, UTF-8 overlong encodings must be rejected. They pose a security hazard anyway. This PR adds new checks that reject UTF-8 overlong encodings. This PR also adds new checks that reject `>U+10FFFF` inputs. Tests are added to cover the above-mentioned functionalities. This includes testing that `isPartiallyPopping()` works in UTF-8 -> UTF-32 conversions, which the function is designed to work. AI Tool Use: I used chatbots for searching when working on this PR. I also used agents to check bugs (which I then fix manually). I don't use LLM-based tool for authoring code in this PR. All code is hand-written by human.
Author
Parents
Loading