fix charset bug

This commit is contained in:
Looly
2020-02-11 16:46:05 +08:00
parent 9cec19b779
commit 804a15a105
2 changed files with 13 additions and 1 deletions

View File

@@ -26,7 +26,18 @@ public class CharsetUtil {
/** UTF-8 */
public static final Charset CHARSET_UTF_8 = StandardCharsets.UTF_8;
/** GBK */
public static final Charset CHARSET_GBK = Charset.forName(GBK);
public static final Charset CHARSET_GBK;
static{
//避免不支持GBK的系统中运行报错 issue#731
Charset _CHARSET_GBK = null;
try{
_CHARSET_GBK = Charset.forName(GBK);
} catch (UnsupportedCharsetException e){
//ignore
}
CHARSET_GBK = _CHARSET_GBK;
}
/**
* 转换为Charset对象