Skip to content

fix: support multi-byte string encodings (GBK, UTF-8) in string helpers - #788

Open
gijzelaerr wants to merge 1 commit into
masterfrom
fix/786-multibyte-string-encoding
Open

fix: support multi-byte string encodings (GBK, UTF-8) in string helpers#788
gijzelaerr wants to merge 1 commit into
masterfrom
fix/786-multibyte-string-encoding

Conversation

@gijzelaerr

Copy link
Copy Markdown
Owner

Summary

  • Replace per-byte chr()/ord() conversion with proper bytes.decode()/str.encode() in get_fstring, get_string, set_fstring, and set_string
  • Add an encoding parameter (default "latin-1" for backward compatibility) to all four functions
  • Enables reading and writing multi-byte strings such as GBK-encoded Chinese text on S7-200 Smart and S7-300 PLCs

Test plan

  • All 1600 existing tests pass (including the TrÖt / TrĪt round-trip tests)
  • mypy, ruff, and pre-commit all pass
  • Manual verification on S7-200 Smart with GBK-encoded FSTRING tags (reporter can verify)

Closes #786

🤖 Generated with Claude Code

…et_string

Replace per-byte chr()/ord() conversion with proper bytes.decode()/str.encode()
and add an `encoding` parameter (default "latin-1" for backward compatibility).
This allows reading and writing multi-byte strings such as GBK-encoded Chinese
text on S7-200 Smart and S7-300 PLCs.

Closes #786

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

关于 S7-200 smart 和 S7-300 PLC 读取标签的不支持中文,需要手动转换

1 participant