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

leading spaces lost #116

Open
zkzkzk40 opened this issue Nov 30, 2024 · 0 comments
Open

leading spaces lost #116

zkzkzk40 opened this issue Nov 30, 2024 · 0 comments

Comments

@zkzkzk40
Copy link

When the text begins with spaces, the current Token encoding implementation ignores these spaces, causing the decoded text to lose its original format. For example:

  • Enter text: " 助手。我很高兴能" (start with a space)
  • Decoded result: "助手。我很高兴能" (leading spaces lost)
String text = " 助手。我很高兴能";
EncodingRegistry registry = Encodings.newDefaultEncodingRegistry();
ENCODING = registry.getEncoding(EncodingType.O200K_BASE);
EncodingResult encodingResult = ENCODING.encodeOrdinary(text, 1);
IntArrayList tokens = encodingResult.getTokens();
String decode = ENCODING.decode(tokens);
System.out.println(decode);
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

No branches or pull requests

1 participant