Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug: when utf 8 multibyte character, ToIntSizedBytes and ToInt16SizedBytes will get a wrong length. #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wangyangcn
Copy link

KafkaNet.Common.Extensions public static byte[] ToIntSizedBytes(this string value) and public static byte[] ToInt16SizedBytes(this string value)
These kafka STRING should use the bytes length, not string length. When we use UTF8 encode the none-ascii characters such as Chinese, the "string.Length" is the number of characters, not the real byte length.

reffer:
http://kafka.apache.org/protocol.html#protocol_types
https://msdn.microsoft.com/en-us/library/system.strings(v=vs.110).aspx

KafkaNet.Common.Extensions  public static byte[] ToIntSizedBytes(this string value) and public static byte[] ToInt16SizedBytes(this string value)
These kafka STRING should use the bytes length, not string length. When we use UTF8 encode the none-ascii characters such as Chinese, the "string.Length" is the number of characters, not the real byte length.

reffer:
http://kafka.apache.org/protocol.html#protocol_types
https://msdn.microsoft.com/en-us/library/system.strings(v=vs.110).aspx
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.

1 participant