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

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

Open
YaoLilin opened this issue Jun 20, 2024 · 0 comments

Comments

@YaoLilin
Copy link

在接收事件时出现事件内容中文乱码
在 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()));

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