当前位置:网站首页>C byte array (byte []) and string are converted to each other
C byte array (byte []) and string are converted to each other
2022-04-23 17:56:00 【It technology ape】
adopt C# Medium system.text.encoding The encoding of the obtained string can be ASCII,DEFAULT,utf-8 And other ways , For English, there is no big difference between these codes , Chinese is very different , among DEFAULT What has been taken is GB2312, It can be confirmed in the following ways , After the program runs, you will find bufOfGB and buf It's the same
string str = "hello, My motherland ";
byte[] bufOfGB = System.Text.Encoding.GetEncoding("gb2312").GetBytes(str);
Array.ForEach(bufOfGB,m=>Console.WriteLine(m));
Console.WriteLine(System.Text.Encoding.Default);
byte[] buf = System.Text.Encoding.Default.GetBytes(str);
Array.ForEach(buf,m=>Console.WriteLine(m));
Console.WriteLine("-------------");
byte[] bufOfASCII = System.Text.Encoding.ASCII.GetBytes(str);
Array.ForEach(bufOfASCII,m=>Console.WriteLine(m));
Console.WriteLine("-------------");
byte[] bufOfUTF = System.Text.Encoding.UTF8.GetBytes(str);
Array.ForEach(bufOfUTF,m=>Console.WriteLine(m));
Console.WriteLine("-------------");
byte[] byteArray ={43,45,67,88,23,1f}
string str = System.Text.Encoding.Default.GetString(byteArray);
版权声明
本文为[It technology ape]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231753552278.html
边栏推荐
- 土地覆盖/利用数据产品下载
- vite配置proxy代理解决跨域
- Halo open source project learning (II): entity classes and data tables
- Listen for click events other than an element
- Nat Commun|在生物科学领域应用深度学习的当前进展和开放挑战
- Utilisation de la liste - Ajouter, supprimer et modifier la requête
- Implementation of image recognition code based on VGg convolutional neural network
- Tell the truth of TS
- YOLOv4剪枝【附代码】
- 102. Sequence traversal of binary tree
猜你喜欢
![Click Cancel to return to the previous page and modify the parameter value of the previous page, let pages = getcurrentpages() let prevpage = pages [pages. Length - 2] / / the data of the previous pag](/img/ed/4d61ce34f830209f5adbddf9165676.png)
Click Cancel to return to the previous page and modify the parameter value of the previous page, let pages = getcurrentpages() let prevpage = pages [pages. Length - 2] / / the data of the previous pag
![C1 notes [task training part 2]](/img/10/48f7490a6c097f2b178ae948cb2c91.png)
C1 notes [task training part 2]

48. Rotate image

JS get link? The following parameter name or value, according to the URL? Judge the parameters after

2022年茶艺师(初级)考试模拟100题及模拟考试

Gaode map search, drag and drop query address

Laser slam theory and practice of dark blue College Chapter 3 laser radar distortion removal exercise

关于gcc输出typeid完整名的方法

2021 Great Wall Cup WP

Tell the truth of TS
随机推荐
92. 反转链表 II-字节跳动高频题
Halo open source project learning (II): entity classes and data tables
2022 Jiangxi Photovoltaic Exhibition, China distributed Photovoltaic Exhibition, Nanchang solar energy utilization Exhibition
[binary number] maximum depth of binary tree + maximum depth of n-ary tree
JS interview question: FN call. call. call. Call (FN2) parsing
587. 安装栅栏 / 剑指 Offer II 014. 字符串中的变位词
云原生虚拟化:基于 Kubevirt 构建边缘计算实例
高德地图搜索、拖拽 查询地址
Index: teach you index from zero basis to proficient use
Transfer learning of five categories of pictures based on VGg
41. The first missing positive number
2022制冷与空调设备运行操作判断题及答案
2021 Great Wall Cup WP
2022 tea artist (primary) examination simulated 100 questions and simulated examination
Romance in C language
239. Maximum value of sliding window (difficult) - one-way queue, large top heap - byte skipping high frequency problem
31. 下一个排列
Add drag and drop function to El dialog
2022年茶艺师(初级)考试模拟100题及模拟考试
极致体验,揭晓抖音背后的音视频技术