Convert UTF-8 and ASCII encoded bytes back to UTF-16 encoded string
来源:互联网 发布:hello kitty主题软件 编辑:程序博客网 时间:2024/05/29 19:22
最近手上在做一个项目,涉及到了编码问题,查了不少资料。看到一些好的资料,留下做记录。
共享一篇国外的关于转码的文章
原文章地址:http://www.sourcecode3s.com/ccsharp/FileStream/Convert_UTF-8_and_ASCII_encoded_bytes_back_to_UTF-16_encoded_string_12273.aspx
using System; using System.IO; using System.Text; class Test { public static void Main() { using (StreamWriter output = new StreamWriter("practice.txt")) { // Create and write a string containing the symbol for Pi. string srcString = "Area = \u03A0r^2"; // Convert the UTF-16 encoded source string to UTF-8 and ASCII. byte[] utf8String = Encoding.UTF8.GetBytes(srcString); byte[] asciiString = Encoding.ASCII.GetBytes(srcString); // Write the UTF-8 and ASCII encoded byte arrays. output.WriteLine("UTF-8 Bytes: {0}", BitConverter.ToString(utf8String)); output.WriteLine("ASCII Bytes: {0}", BitConverter.ToString(asciiString)); // Convert UTF-8 and ASCII encoded bytes back to UTF-16 encoded // string and write. output.WriteLine("UTF-8 Text : {0}", Encoding.UTF8.GetString(utf8String)); output.WriteLine("ASCII Text : {0}", Encoding.ASCII.GetString(asciiString)); Console.WriteLine(Encoding.UTF8.GetString(utf8String)); Console.WriteLine(Encoding.ASCII.GetString(asciiString)); } }}
- Convert UTF-8 and ASCII encoded bytes back to UTF-16 encoded string
- encode_json 会对给定的Perl的数据结构转换为一个UTF-8 encoded, binary string.
- python unicode bytes ascii utf-8
- convert utf-8 to ansi
- C Tips: Convert LPCTSTR to UTF-8 string
- Set MySQL to use UTF-8 and convert database
- char* convert to string and back
- ASCII,Unicode和UTF-8,UTF-16
- ASCII Unicode utf-8 utf-16
- unicode 和 utf-8 utf-16 utf-32 ASCII ANSI
- Python出现TypeError: file() argument 1 must be encoded string without NULL bytes, not str问题解决
- 解决 Subversion 的 “svn: Can't convert string from 'UTF-8' to native encoding” 错误
- Can't convert string from native encoding to 'UTF-8' problems
- 解决 Subversion 的 “svn: Can't convert string from 'UTF-8' to native encoding” 错误
- svn: Can't convert string from 'UTF-8' to native encoding 的解决办法
- SVN UP 命令出现错误:Can't convert string from 'UTF-8' to native encoding:
- 关于svn: Can't convert string from 'UTF-8' to native encoding的解决办法
- 解决 Subversion 的 “svn: Can't convert string from 'UTF-8' to native encoding” 错误
- Union和Union All的区别
- RapidXml使用方法
- 【Android UI设计与开发】第02期:引导界面(二)使用ViewPager实现欢迎引导页面
- 几个必要的名词解释 光圈 焦距 速度 景深 iso
- struts2 拦截器配置 表单数据丢失问题
- Convert UTF-8 and ASCII encoded bytes back to UTF-16 encoded string
- web应用打war包
- 【Android UI设计与开发】第03期:引导界面(三)仿微信引导界面以及动画效果
- Yii框架的事件(Event)和行为(Behavior)
- 架包Error inflating class错误
- 非常好的资料--现在非常需要
- 求霍夫曼扩展编码
- ios判断是否为数字(全拼数字)
- 数据结构中三表合一的实现