[PR #4093] Implement til::u8u16 and til::u16u8 conversion functions #25636

Open
opened 2026-01-31 09:10:47 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/4093

State: closed
Merged: Yes


Summary of the Pull Request

PR Checklist

Detailed Description of the Pull Request / Additional comments

On my list:

  1. ✔ Implement UTF-8 <--> UTF-16 conversion in user mode (this PR)
    1.1. ✔ Transpose my U8ToU16() and U16ToU8() C --> C++ (obsolet)
    1.2. ✔ Implement functors for partials handling
    1.3. ✔ Implement functors to do both the partials handling and the conversion task at once
    1.4. ✔ Supersede Utf8OutPipeReader and remove it from the code base to avoid further use
  2. Unify UTF-8 handling (supersede Utf8ToWideCharParser)
    2.1. Update VtInputThread::_HandleRunInput()
    2.2. Update ApiRoutines::WriteConsoleAImpl()
    2.3. (optional / ask the core team) Remove Utf8ToWideCharParser from the code base to avoid further use
  3. Enable BOM discarding
    3.1. Implement an enum class containing flags for U8ToU16() and U16ToU8() to enable discarding both BOM and/or invalids
    3.2. Replace the 3rd parameter of U8ToU16(), U16ToU8(), and related functors with the enum and update the function code accordingly
    3.3. Make use of the 3rd parameter to discard the BOM in all current functor callers, or (optional / ask the core team) make it the default for U8ToU16() and U16ToU8()
  4. Find UTF-16 to UTF-8 conversions and examine if they can be unified, too

Validation Steps Performed

  • Unit tests implemented.
  • Loads of manual tests to evaluate the behavior of the implemented code.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/4093 **State:** closed **Merged:** Yes --- <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request * Remove `UTF8OutputPipeReader`, move the pipe reading back to `ConptyConnection::_OutputThread()`. * Implement UTF-8 <--> UTF-16 conversion ~~in user mode. Enable to toggle between ignoring invalid UTF-8 and replacing it with U+FFFD.~~ See #3378 * Implement a re-usable partials handling. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #4092 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [ ] Requires documentation to be updated * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments On my list: 1. ✔ Implement UTF-8 <--> UTF-16 conversion ~~in user mode~~ (this PR) 1.1. ✔ ~~Transpose my U8ToU16() and U16ToU8() C --> C++~~ (obsolet) 1.2. ✔ Implement functors for partials handling 1.3. ✔ Implement functors to do both the partials handling and the conversion task at once 1.4. ✔ Supersede Utf8OutPipeReader and remove it from the code base to avoid further use 2. ❌ Unify UTF-8 handling (supersede Utf8ToWideCharParser) 2.1. ❌ Update VtInputThread::_HandleRunInput() 2.2. ❌ Update ApiRoutines::WriteConsoleAImpl() 2.3. ❌ (optional / ask the core team) Remove Utf8ToWideCharParser from the code base to avoid further use 3. ❌ Enable BOM discarding 3.1. ❌ Implement an `enum class` containing flags for U8ToU16() and U16ToU8() to enable discarding both BOM and/or invalids 3.2. ❌ Replace the 3rd parameter of U8ToU16(), U16ToU8(), and related functors with the enum and update the function code accordingly 3.3. ❌ Make use of the 3rd parameter to discard the BOM in all current functor callers, or (optional / ask the core team) make it the default for U8ToU16() and U16ToU8() 4. ❌ Find UTF-16 to UTF-8 conversions and examine if they can be unified, too <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed * Unit tests implemented. * Loads of manual tests to evaluate the behavior of the implemented code.
claunia added the pull-request label 2026-01-31 09:10:47 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25636