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

Add encoding utils #179

Merged
merged 6 commits into from
May 29, 2023
Merged

Conversation

HzjNeverStop
Copy link
Contributor

No description provided.

“HzjNeverStop” added 2 commits May 19, 2023 11:27
@codecov
Copy link

codecov bot commented May 26, 2023

Codecov Report

Merging #179 (fdf9f22) into master (9ed95ec) will increase coverage by 0.13%.
The diff coverage is 51.06%.

@@             Coverage Diff              @@
##             master     #179      +/-   ##
============================================
+ Coverage     34.60%   34.73%   +0.13%     
- Complexity      662      676      +14     
============================================
  Files            75       76       +1     
  Lines          5627     5674      +47     
  Branches       1075     1089      +14     
============================================
+ Hits           1947     1971      +24     
- Misses         3436     3450      +14     
- Partials        244      253       +9     
Impacted Files Coverage Δ
...java/com/alipay/sofa/common/utils/CharsetUtil.java 51.06% <51.06%> (ø)

“HzjNeverStop” added 2 commits May 29, 2023 10:44
@OrezzerO
Copy link
Contributor

I don't think it is a good idea to check if a byte array is UTF-8 encoded. It is more reasonable to test if default charset is UTF-8.

*/
public class CharsetUtil {

public static Logger CHARSET_MONITOR_LOG = LoggerFactory.getLogger("CHARSET_MONITOR_LOG");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个配置方式是希望用户自己配 CHARSET_MONITOR_LOG 吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个配置方式是希望用户自己配 CHARSET_MONITOR_LOG 吗?

是的,用户自己配置 LOGGER 更加灵活,例如可以为日志打印添加MDC(traceId、方法入参)

@HzjNeverStop
Copy link
Contributor Author

I don't think it is a good idea to check if a byte array is UTF-8 encoded. It is more reasonable to test if default charset is UTF-8.

This utility class is used to detect whether a system that uses UTF-8 encoding has read non-UTF-8 encoded data from other data streams.

Copy link
Member

@ujjboy ujjboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HzjNeverStop HzjNeverStop merged commit efa6342 into sofastack:master May 29, 2023
3 checks passed
HzjNeverStop added a commit to HzjNeverStop/sofa-common-tools that referenced this pull request Jun 2, 2023
(cherry picked from commit efa6342)
HzjNeverStop added a commit that referenced this pull request Jun 2, 2023
* Add encoding utils (#179)

(cherry picked from commit efa6342)

* Add LegacySpringBanUtil (#180)

Co-authored-by: “HzjNeverStop” <“441627022@qq.com”>
(cherry picked from commit 99d321b)
HzjNeverStop added a commit that referenced this pull request Jun 28, 2023
* 2.0.0 (#176)

- 升级 JDK17
- 适配 slf4j2 与 reload4j
- 升级 log4j2 与 logback 版本
- 移除 @deprecated 代码

* 2.0.0 fix javadoc (#177)

* use reload log4j (#178)

Co-authored-by: “HzjNeverStop” <“441627022@qq.com”>

* use singleton console appender for space

* update CommonLoggingConfigurations

* update maven stage plugin to 1.6.13

* Merge 1.3.11 (#182)

* Add encoding utils (#179)

(cherry picked from commit efa6342)

* Add LegacySpringBanUtil (#180)

Co-authored-by: “HzjNeverStop” <“441627022@qq.com”>
(cherry picked from commit 99d321b)

* release 2.0.0 (#183)

Co-authored-by: “HzjNeverStop” <“441627022@qq.com”>

---------

Co-authored-by: “HzjNeverStop” <“441627022@qq.com”>
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.

None yet

3 participants