[PR #4685] [MERGED] Ensure til::u8u16 still works if the string consists of just a lead byte #25884

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4685
Author: @german-one
Created: 2/21/2020
Status: Merged
Merged: 2/21/2020
Merged by: @undefined

Base: masterHead: dev/duhowett/cherry-pick-3003


📝 Commits (1)

  • 6f7ee74 make sure caching of partials still works if the string consists of a single lead byte only (GH#4673)

📊 Changes

2 files changed (+33 additions, -9 deletions)

View changed files

📝 src/inc/til/u8u16convert.h (+2 -2)
📝 src/til/ut_til/u8u16convertTests.cpp (+31 -7)

📄 Description

Summary of the Pull Request

Fixes a flaw that happened if til::u8u16 received a single lead byte.

PR Checklist

Detailed Description of the Pull Request / Additional comments

The loop for caching partials didn't run and thus, the lead byte was
converted to U+FFFD. That's because the loop starts with sequenceLen
initialized with 1. And if the string has a length of 1 the initial
condition is 1<1 which is evaluated to false and the body of the
loop was never executed.

Validation Steps Performed

  1. updated the code of the state class and tested manually that printf "\xE2"; printf "\x98\xBA\n" prints a U+263A character
  2. updated the unit tests to make sure that still up to 3 partials are
    cached
  3. updated the unit tests to make sure caching also works if the string
    consists of a lead byte only
  4. tested manually that #4086 is still resolved

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4685 **Author:** [@german-one](https://github.com/german-one) **Created:** 2/21/2020 **Status:** ✅ Merged **Merged:** 2/21/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/duhowett/cherry-pick-3003` --- ### 📝 Commits (1) - [`6f7ee74`](https://github.com/microsoft/terminal/commit/6f7ee744c601bdb90d0de446493df89d38d66664) make sure caching of partials still works if the string consists of a single lead byte only (GH#4673) ### 📊 Changes **2 files changed** (+33 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src/inc/til/u8u16convert.h` (+2 -2) 📝 `src/til/ut_til/u8u16convertTests.cpp` (+31 -7) </details> ### 📄 Description ## Summary of the Pull Request Fixes a flaw that happened if `til::u8u16` received a single lead byte. ## PR Checklist * [x] Closes #4673 * [x] Tests added/passed ## Detailed Description of the Pull Request / Additional comments The loop for caching partials didn't run and thus, the lead byte was converted to U+FFFD. That's because the loop starts with `sequenceLen` initialized with 1. And if the string has a length of 1 the initial condition is `1<1` which is evaluated to `false` and the body of the loop was never executed. ## Validation Steps Performed 1) updated the code of the state class and tested manually that `printf "\xE2"; printf "\x98\xBA\n"` prints a U+263A character 2) updated the unit tests to make sure that still up to 3 partials are cached 3) updated the unit tests to make sure caching also works if the string consists of a lead byte only 4) tested manually that #4086 is still resolved --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:12:25 +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#25884