java中各种编码转换

java中各种编码转换

ID:17177584

大小:197.50 KB

页数:10页

时间:2018-08-28

java中各种编码转换_第1页
java中各种编码转换_第2页
java中各种编码转换_第3页
java中各种编码转换_第4页
java中各种编码转换_第5页
资源描述:

《java中各种编码转换》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、importjava.io.UnsupportedEncodingException;/** *转换字符串的编码 */publicclassChangeCharset{ /** 7位ASCII字符,也叫作ISO646-US、Unicode字符集的基本拉丁块 */ publicstaticfinalStringUS_ASCII="US-ASCII"; /** ISO拉丁字母表No.1,也叫作ISO-LATIN-1 */ publicstaticfinalStringISO_8859_1="ISO-8859-1"; /** 8位UCS转换格式 */ publi

2、cstaticfinalStringUTF_8="UTF-8"; /** 16位UCS转换格式,BigEndian(最低地址存放高位字节)字节顺序 */ publicstaticfinalStringUTF_16BE="UTF-16BE"; /** 16位UCS转换格式,Little-endian(最高地址存放低位字节)字节顺序 */ publicstaticfinalStringUTF_16LE="UTF-16LE"; /** 16位UCS转换格式,字节顺序由可选的字节顺序标记来标识 */ publicstaticfinalStringUTF_16="U

3、TF-16"; /** 中文超大字符集 */ publicstaticfinalStringGBK="GBK"; /** *将字符编码转换成US-ASCII码 */ publicStringtoASCII(Stringstr)throwsUnsupportedEncodingException{  returnthis.changeCharset(str,US_ASCII); } /** *将字符编码转换成ISO-8859-1码 */ publicStringtoISO_8859_1(Stringstr)throwsUnsupportedEncodingE

4、xception{  returnthis.changeCharset(str,he"governingforthepeople","Nomattertheinterestsofthemasses"conceptunderstandingisnotinplace.Thespecificworktreatswiththedeployment,afewleadingcadrescomplainthatworkistoocomplicated,toomuchresponsibility,thepressureistoolarge,toomuchemphasiso

5、nthedifficultyofthework.Forexample,noncoalmineISO_8859_1); } /** *将字符编码转换成UTF-8码 */ publicStringtoUTF_8(Stringstr)throwsUnsupportedEncodingException{  returnthis.changeCharset(str,UTF_8); } /** *将字符编码转换成UTF-16BE码 */ publicStringtoUTF_16BE(Stringstr)throwsUnsupportedEncodingExcepti

6、on{  returnthis.changeCharset(str,UTF_16BE); } /** *将字符编码转换成UTF-16LE码 */ publicStringtoUTF_16LE(Stringstr)throwsUnsupportedEncodingException{  returnthis.changeCharset(str,UTF_16LE); } /** *将字符编码转换成UTF-16码 */ publicStringtoUTF_16(Stringstr)throwsUnsupportedEncodingException{  retu

7、rnthis.changeCharset(str,UTF_16); } /** *将字符编码转换成GBK码 */ publicStringtoGBK(Stringstr)throwsUnsupportedEncodingException{  returnthis.changeCharset(str,GBK); }  /** *字符串编码转换的实现方法 *@paramstr  待转换编码的字符串 *@paramnewCharset 目标编码 *@return *@throwsUnsupportedEncodingException */ publicStr

8、ingchangeCharset(Stringstr,String

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。