许明会的计算机技术主页

Language:C,C++,.NET Framework(C#)
Thinking:Design Pattern,Algorithm,WPF,Windows Internals
Database:SQLServer,Oracle,MySQL,PostSQL
IT:MCITP,Exchange,Lync,Virtualization,CCNP

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

System.Text.Encoding.UTF8 字符串和字节数组的互相转换


/*--===------------------------------------------===--
so lang to write code , now i'm free to code again,ha.
this time, let's see a demo, Encoding.
xuminghui, 2008-05-14 @home
--===------------------------------------------===---
*/


namespace xumh
{
    
public class EncodingTest
    
{
        
public static void Main()
        
{
            System.Console.Write(
"Input String, test Encoding:");
            
string input = System.Console.ReadLine();
            
//here, get the Byte Array of the String
            byte[] encodeBytes = System.Text.Encoding.UTF8.GetBytes(input);
            System.Console.WriteLine(
"Encoding Bytes:{0}",System.BitConverter.ToString(encodeBytes));
            
//here, get the String of the Bytes
            string gets = System.Text.Encoding.UTF8.GetString(encodeBytes);
            System.Console.WriteLine(
"Encoding String:{0}",gets);
            System.Console.ReadLine();
        }

    }

}

posted on   许明会  阅读(4475)  评论(1编辑  收藏  举报

点击右上角即可分享
微信分享提示