tjiuming opened a new pull request, #18138: URL: https://github.com/apache/pulsar/pull/18138
### Motivation For the method [SimpleTextOutputStream](https://github.com/apache/pulsar/blob/master/pulsar-common/src/main/java/org/apache/pulsar/common/util/SimpleTextOutputStream.java)#write(String), it's implementation as below: ``` public SimpleTextOutputStream write(String s) { if (s == null) { return this; } int len = s.length(); for (int i = 0; i < len; i++) { buffer.writeByte((byte) s.charAt(i)); } return this; } ``` Generally, it works fine. But if there is a character has different length in different encoding, it would lead to an issue, say `¬`. In latin1, it's bytes is [-84], by calling `"¬".getBytes(StandardCharset.ISO_8859_1)` but in UTF8, it's bytes is [-62, -84], by calling `"¬".getBytes(StandardCharset.UTF_8)` if we replace `str.getBytes(charset)` with `(byte) s.charAt(i)`, `¬` will display as `�`. ### Documentation <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR description, or else your PR might not get merged. --> - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later --> - [x] `doc-not-needed` <!-- Your PR changes do not impact docs --> - [ ] `doc-complete` <!-- Docs have been already added --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
