SIGN IN SIGN UP

[flutter_tools] Compute LSP Content-Length header using UTF-8 byte length (#191377)

## Description

Fixes `flutter analyze` crashing with `FormatException: Unexpected end
of input` when analyzing a project whose path contains non-ASCII
characters (e.g. `Alexander’s MacBook Pro` with right single quotation
mark `’` / U+2019).

In `AnalysisServer._writeMessage`, the `Content-Length` header was being
calculated using `message.length` (UTF-16 code units) rather than the
UTF-8 encoded byte length required by the LSP specification. When
messages contained multibyte Unicode characters (such as in `rootUri` or
`workspaceFolders`), the header under-reported the payload length,
causing the analysis server's JSON parser to receive a truncated payload
and exit prematurely with code 255.

Also updates `MockLspServerProcess` to parse stdin as a stream of raw
bytes and compute outgoing message length in bytes to faithfully
simulate the LSP transport layer.

## Related Issues
Fixes https://github.com/flutter/flutter/issues/191309

## Tests
- Added `AnalysisServer handles non-ASCII project path` unit test in
`packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart`.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
B
Ben Konyi committed
911c485a9db21744226ae9c8102a809d0d12b585
Parent: 0cc8a14
Committed by GitHub <noreply@github.com> on 8/20/2026, 6:01:12 PM