larksuite / larksuite/oapi-sdk-java

事件内容中文乱码-能否在读取事件内容时强制使用UTF-8读取

Open
#126 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
310
Forks
115
PR merge metrics
No merged PRs in 30d

Description

在接收事件时出现事件内容中文乱码
在 HttpTranslator 类的 translate 方法中:
String bodyStr = (String)request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
如果环境的默认字符集不是UTF-8,则会出现中文乱码,推荐强制使用UTF-8进行读取,如:
BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream(), StandardCharsets.UTF_8));
String content = reader.lines().collect(Collectors.joining(System.lineSeparator()));

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the HttpTranslator.translate method and inspect how the request body is read from the HttpServletRequest. Verify the behavior when the environment's default charset is not UTF-8, then ensure event content is decoded as UTF-8 and confirm that Chinese content is no longer garbled.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.