public class ChangeCharset extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
GBK
中文超大字符集
|
static String |
ISO_8859_1
ISO 拉丁字母表 No.1,也叫作 ISO-LATIN-1
|
static String |
US_ASCII
7位ASCII字符,也叫作ISO646-US、Unicode字符集的基本拉丁块
|
static String |
UTF_16
16 位 UCS 转换格式,字节顺序由可选的字节顺序标记来标识
|
static String |
UTF_16BE
16 位 UCS 转换格式,Big Endian(最低地址存放高位字节)字节顺序
|
static String |
UTF_16LE
16 位 UCS 转换格式,Little-endian(最高地址存放低位字节)字节顺序
|
static String |
UTF_8
8 位 UCS 转换格式
|
| Constructor and Description |
|---|
ChangeCharset() |
| Modifier and Type | Method and Description |
|---|---|
static String |
bytes2Str(byte[] b) |
String |
changeCharset(String str,
String newCharset)
字符串编码转换的实现方法
|
String |
changeCharset(String str,
String oldCharset,
String newCharset)
字符串编码转换的实现方法
|
static void |
main(String[] args) |
String |
toASCII(String str)
将字符编码转换成US-ASCII码
|
String |
toGBK(String str)
将字符编码转换成GBK码
|
String |
toISO_8859_1(String str)
将字符编码转换成ISO-8859-1码
|
String |
toUTF_16(String str)
将字符编码转换成UTF-16码
|
String |
toUTF_16BE(String str)
将字符编码转换成UTF-16BE码
|
String |
toUTF_16LE(String str)
将字符编码转换成UTF-16LE码
|
String |
toUTF_8(String str)
将字符编码转换成UTF-8码
|
public static final String US_ASCII
public static final String ISO_8859_1
public static final String UTF_8
public static final String UTF_16BE
public static final String UTF_16LE
public static final String UTF_16
public static final String GBK
public String toASCII(String str) throws UnsupportedEncodingException
str - 字符串UnsupportedEncodingException - 异常public String toISO_8859_1(String str) throws UnsupportedEncodingException
str - 字符串UnsupportedEncodingException - 异常public String toUTF_8(String str) throws UnsupportedEncodingException
str - 字符串UnsupportedEncodingException - 异常public String toUTF_16BE(String str) throws UnsupportedEncodingException
str - 字符串UnsupportedEncodingException - 异常public String toUTF_16LE(String str) throws UnsupportedEncodingException
str - 字符串UnsupportedEncodingException - 异常public String toUTF_16(String str) throws UnsupportedEncodingException
str - 字符串UnsupportedEncodingException - 异常public String toGBK(String str) throws UnsupportedEncodingException
str - 字符串UnsupportedEncodingException - 异常public String changeCharset(String str, String newCharset) throws UnsupportedEncodingException
str - 待转换编码的字符串newCharset - 目标编码UnsupportedEncodingException - 异常public String changeCharset(String str, String oldCharset, String newCharset) throws UnsupportedEncodingException
str - 待转换编码的字符串oldCharset - 原编码newCharset - 目标编码UnsupportedEncodingException - 异常public static String bytes2Str(byte[] b)
public static void main(String[] args) throws UnsupportedEncodingException
UnsupportedEncodingExceptionCopyright © 2017. All rights reserved.