[PR #2237] [CLOSED] fix(adb): logcat total_bytes counts UTF-8 bytes instead of UTF-16 code units #5105

Closed
opened 2026-10-31 01:03:57 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2237
Author: @Gideon145
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: fix-adb-logcat-total-bytes


📝 Commits (1)

  • d56c7aa fix(adb): logcat total_bytes counts UTF-8 bytes instead of UTF-16 code units

📊 Changes

2 files changed (+17 additions, -1 deletions)

View changed files

📝 src/adb/AdbProvider.test.ts (+16 -0)
📝 src/adb/AdbProvider.ts (+1 -1)

📄 Description

## The problem

read-adb-logcat assigned ran.value.stdout.length to total_bytes. JavaScript string .length counts UTF-16 code units, so captured UTF-8 text with CJK or emoji characters reported fewer bytes than were actually captured. A 37-byte CJK log line reported total_bytes: 33, and an emoji line reported 33 instead of 35.

The change

total_bytes is now Buffer.byteLength(stdout, "utf8"), which counts the encoded bytes of the captured dump. The capture boundary already guarantees a complete buffer (truncation is rejected as a resource constraint error before decoding), so the re-encoded byte length equals the captured byte count exactly.

Test

Added a regression test with multibyte output: one CJK line and one emoji line, asserting total_bytes equals Buffer.byteLength(dump, "utf8") and the decoded lines are unchanged.

Fixes #2175.


🔄 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/morluto/rea/pull/2237 **Author:** [@Gideon145](https://github.com/Gideon145) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-adb-logcat-total-bytes` --- ### 📝 Commits (1) - [`d56c7aa`](https://github.com/morluto/rea/commit/d56c7aa70a9a21d49b07c17fa7c72a840d7bc8af) fix(adb): logcat total_bytes counts UTF-8 bytes instead of UTF-16 code units ### 📊 Changes **2 files changed** (+17 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/adb/AdbProvider.test.ts` (+16 -0) 📝 `src/adb/AdbProvider.ts` (+1 -1) </details> ### 📄 Description ## The problem `read-adb-logcat` assigned `ran.value.stdout.length` to `total_bytes`. JavaScript string `.length` counts UTF-16 code units, so captured UTF-8 text with CJK or emoji characters reported fewer bytes than were actually captured. A 37-byte CJK log line reported `total_bytes: 33`, and an emoji line reported 33 instead of 35. ## The change `total_bytes` is now `Buffer.byteLength(stdout, "utf8")`, which counts the encoded bytes of the captured dump. The capture boundary already guarantees a complete buffer (truncation is rejected as a resource constraint error before decoding), so the re-encoded byte length equals the captured byte count exactly. ## Test Added a regression test with multibyte output: one CJK line and one emoji line, asserting `total_bytes` equals `Buffer.byteLength(dump, "utf8")` and the decoded lines are unchanged. Fixes #2175. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:03:57 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5105
No description provided.