[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
常用字符编码
在程序中如果没有处理好字符的编码,就有可能出现乱码问题。下面我们一起为大家介绍在开 发中常见的编码有 哪些。
在计算机世界里,任何的文字都是以指定的编码方式存在的。 常见编码有: |S08859-1、GBK/GB2312、 unicode、 UTF。
iso8859-1: 编码属于单字节编码,最多只能表示0- -- -255的字符范围,主要在英文上应用。 GBK/GB2312: 中文的国际编码,专门
门用来表示汉字,是双字节编码
unicode:I java中就是使用此编码方式,也是最标准的一种编码,是使用16进制表示的编码。但此编码不兼容iso8859- 1编码。 UTF:
由于unicode不支持iso8859- 1编码,而且容易占用更多的空间,而且对于英文母也需要使用两个字节编码,这样使
用unicode不便于传输和储存,因此产生了utf编码,utt编码兼容了iso8859- 1编码,也可以用来表示所有语言字符,
不过utf是不定长编码,每个字符的长度从1- 6个字节不等,-般在中文网页中使用此编码,因为这样可以节省空 间。 造成乱码的根本原因:
1、程序使用的编码与本机的编码不统一 2、在网络中,客户端与服务端编码不统一
package IODemo; import java.io.UnsupportedEncodingException; public class
CodeDemo { //通常产生乱码的情况是,两个不兼容的编码互相转换; public static void main(String[]
args) { String info = "天命不可违";//GB2312 try { String
newInfo = new String(info.getBytes("gb2312"),"iso8859-1");
System.out.println(newInfo); String newInfo2 = new
String(newInfo.getBytes("iso8859-1"),"gb2312");
System.out.println(newInfo2); } catch (UnsupportedEncodingException e) {
e.printStackTrace(); } } }