larksuite / larksuite/oapi-sdk-java
事件内容中文乱码-能否在读取事件内容时强制使用UTF-8读取
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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