日期:2014-05-17  浏览次数:20402 次

"骞垮窞"和"广州"这两个词在编码上是怎么转换的呢?
传输的"广州",应该是经过错误的处理得到了"骞垮窞"这个词。
有没有人知道是经过怎样的编码转换呢?
"广州"的utf-8:%e5%b9%bf%e5%b7%9e
"骞垮窞"的utf-8:%e9%aa%9e%e5%9e%ae%e7%aa%9e

求解啊

------解决方案--------------------
你应该告诉大家,你用什么传输协议?是否存在设置位的漏洞?或缺少其他设置?从哪里传输到哪里?
------解决方案--------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = "骞垮窞";
            string s2 = "广州";
            byte[] b1 = Encoding.UTF8.GetBytes(s1);
            byte[] b2 = Encoding.UTF8.GetBytes(s2);
            ShowBytes(b1);
            Console.WriteLine();
            ShowBytes(b2);
        }

        static void ShowBytes(byte[] data)
        {
            Console.WriteLine(string.Join(" ", data.SelectMany(x => new int[] { x / 16, x % 16 }).Select(x => Convert.ToString(x, 2).PadLeft(4, '0'))));
            Console.WriteLine(string.Join(" ", data.Select(x => Convert.ToString(x, 2).PadLeft(8, '0'))));
            Console.WriteLine(string.Join(" ", data.Select(x => Convert.ToString(x, 16).ToUpper().PadLeft(2, '0'))));
        }
    }
}


1110 1001 1010 1010 1001 1110 1110 0101 1001 1110 1010 1110 1110 0111 1010 1010
1001 1110
11101001 10101010 10011110 11100101 10011110 10101110 11100111 10101010 10011110

E9 AA 9E E5 9E AE E7 AA 9E

1110 0101 1011 1001 1011 1111 1110 0101 1011 0111 1001 1110
11100101 10111001 10111111 11100101 10110111 10011110
E5 B9 BF E5 B7 9E
Press any key to continue . . .


有没有别的例子,一个实在看不出规律。

你也可以用我的代码自己去分析。