Skip to content

fix: correct Utf8String encoding and dynamic array handling for non-ASCII strings (#1841)#2289

Open
Dev10-sys wants to merge 1 commit intoLFDT-web3j:mainfrom
Dev10-sys:fix/utf8string-chinese-encoding-1841
Open

fix: correct Utf8String encoding and dynamic array handling for non-ASCII strings (#1841)#2289
Dev10-sys wants to merge 1 commit intoLFDT-web3j:mainfrom
Dev10-sys:fix/utf8string-chinese-encoding-1841

Conversation

@Dev10-sys
Copy link
Copy Markdown
Contributor

Fixes incorrect handling of UTF-8 strings (e.g., Chinese text) which could lead to wrong encoding or transaction failures.

The string length calculation has been updated to use actual UTF-8 byte length with proper ABI padding and array encoding has been corrected to handle static arrays containing dynamic types properly.

Additional tests have been added to cover non-ASCII strings and edge cases.

Fixes #1841

…-web3j#1841)

- fixed Utf8String.bytes32PaddedLength calculation to use actual byte length for non-ASCII characters
- updated TypeEncoder to correctly identify and encode static arrays of dynamic types with proper offsets
- added comprehensive test cases for Chinese strings, long multi-byte strings, and empty strings
- resolved compilation issues in existing tests on Windows by replacing literal characters with Unicode escapes
- updated CHANGELOG.md with the bug fix entry

Signed-off-by: Dev10-sys <kalpanagola9897@gmail.com>
@Dev10-sys Dev10-sys force-pushed the fix/utf8string-chinese-encoding-1841 branch from b806b2f to 7524f6d Compare May 4, 2026 05:06
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.

utf8string[] can not process the chinese words correctly

1 participant