[PR #4493] Implement til::au16 and til::u16a conversion functions & make first use in WriteConsoleAImpl #25789

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

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

State: closed
Merged: No


Summary of the Pull Request

Implement conversion functions that complement the existing til::u8u16 and til::u16u8 for the use along with other codepages than UTF-8. A state class will take care of partials at the boundaries of DBCS-encoded text.

References

Proposed in https://github.com/microsoft/terminal/pull/4422#discussion_r374364170

PR Checklist

  • Closes #xxx
  • CLA signed. If not, go over here and sign the CLA
  • 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

Detailed Description of the Pull Request / Additional comments

These functions have the potential to supersede ConvertToW and ConvertToA by adding partials handling.
NOTE: The astate class supports only a subset of the possible codepages (see the remarks in the code).

In order to see how it works I updated WriteConsoleAImpl accordingly.
I plan to search the code base for more points to apply these functions to, and commit those updates in an upcoming PR.

Validation Steps Performed

  • long DBCS strings split into short chunks with an odd number of bytes, and outputted to the console using WriteConsoleA
  • unit test added
**Original Pull Request:** https://github.com/microsoft/terminal/pull/4493 **State:** closed **Merged:** No --- <!-- 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 Implement conversion functions that complement the existing `til::u8u16` and `til::u16u8` for the use along with other codepages than UTF-8. A state class will take care of partials at the boundaries of DBCS-encoded text. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References Proposed in https://github.com/microsoft/terminal/pull/4422#discussion_r374364170 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [ ] Closes #xxx * [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 These functions have the potential to supersede `ConvertToW` and `ConvertToA` by adding partials handling. NOTE: The `astate` class supports only a subset of the possible codepages (see the remarks in the code). In order to see how it works I updated `WriteConsoleAImpl` accordingly. I plan to search the code base for more points to apply these functions to, and commit those updates in an upcoming PR. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed - long DBCS strings split into short chunks with an odd number of bytes, and outputted to the console using `WriteConsoleA` - unit test added
claunia added the pull-request label 2026-01-31 09:11: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#25789