Skip to content

Conversation

@majiayu000
Copy link

Summary

  • Change text=True to text=False in subprocess.run calls for screenshot operations
  • Add explicit UTF-8 decoding with errors='replace' for error output handling
  • Add tests to verify binary mode usage

Problem

When capturing screenshots, the ADB commands may produce binary data or surrogate characters that cause:

UnicodeEncodeError: 'utf-8' codec can't encode characters in position X-Y: surrogates not allowed

Solution

Use binary mode (text=False) for subprocess calls and decode output with proper error handling.

Fixes #224

… errors

Change subprocess.run calls from text=True to text=False for screenshot
operations. This prevents UnicodeEncodeError when handling binary PNG data
or surrogate characters in ADB output.

The output is now explicitly decoded with errors='replace' to gracefully
handle any non-UTF-8 characters.

Fixes zai-org#224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

截图捕获中的 UTF-8 编码错误

1 participant