请问一个转码问题,没明白是什么转码,请大家看看

renmms 2012-12-24 10:18:28
汉字:

专家称近期气温以偏低为主,是否“寒冬”不能确定

编码:
4e135bb679f08fd1671f6c146e294ee5504f4f4e4e3a4e3bff0c662f5426201c5bd251ac201d4e0d80fd786e5b9a


------------------


请问这个是什么编码,我能得到编码,怎么转成汉字?

多谢!
...全文
362 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangbinykit 2012-12-26
  • 打赏
  • 举报
回复
byte[] bytes = Regex.Matches(s, "[0-9a-fA-F]{2}").Cast<Match>().Select(x => (byte)Convert.ToInt16("0x" + x.Value, 16)).ToArray(); 从没想过还能有这种写法
风吹腚腚凉 2012-12-25
  • 打赏
  • 举报
回复
引用 13 楼 caozhy 的回复:
引用 12 楼 marclee44 的回复: 引用 11 楼 caozhy 的回复:byte[] bytes = Regex.Matches(s, "[0-9a-fA-F]{2}").Cast<Match>().Select(x => (byte)Convert.ToInt16("0x" + x.Value, 16)).ToArray(); 学习下 扯淡,代码根本不值得学习,要学习的是方……
学习一下
threenewbee 2012-12-25
  • 打赏
  • 举报
回复
引用 17 楼 marclee44 的回复:
我从没考虑过正则去做,这是我要学习的地方 我通常的转法 C# code?123456 byte[] array = new byte[s.Length / 2]; for (int i = 0; i < s.Length / 2; i++) { string str = s……
哦,其实这和转码没有太大关系,只是给lz演示构造测试数据。
Marky 2012-12-25
  • 打赏
  • 举报
回复
我从没考虑过正则去做,这是我要学习的地方 我通常的转法
            byte[] array = new byte[s.Length / 2];
            for (int i = 0; i < s.Length / 2; i++)
            {
                string str = s.Substring(i, 2);
                array[i] =(byte)Convert.ToInt32(str ,16);;
            }
threenewbee 2012-12-25
  • 打赏
  • 举报
回复
引用 15 楼 marclee44 的回复:
引用 13 楼 caozhy 的回复:引用 12 楼 marclee44 的回复:引用 11 楼 caozhy 的回复:byte[] bytes = Regex.Matches(s, "[0-9a-fA-F]{2}").Cast<Match>().Select(x => (byte)Convert.ToInt16("0x" + x.Value, 16)).ToArray(……
难道还有别的“思路”?
Marky 2012-12-25
  • 打赏
  • 举报
回复
引用 13 楼 caozhy 的回复:
引用 12 楼 marclee44 的回复:引用 11 楼 caozhy 的回复:byte[] bytes = Regex.Matches(s, "[0-9a-fA-F]{2}").Cast<Match>().Select(x => (byte)Convert.ToInt16("0x" + x.Value, 16)).ToArray(); 学习下 扯淡,代码根本不……
只是学习下思路,以前没考虑过还能这么转而已
言多必失 2012-12-24
  • 打赏
  • 举报
回复
路过
threenewbee 2012-12-24
  • 打赏
  • 举报
回复
引用 12 楼 marclee44 的回复:
引用 11 楼 caozhy 的回复:byte[] bytes = Regex.Matches(s, "[0-9a-fA-F]{2}").Cast<Match>().Select(x => (byte)Convert.ToInt16("0x" + x.Value, 16)).ToArray(); 学习下
扯淡,代码根本不值得学习,要学习的是方法。好比你天天吃红烧肉,你能学到厨艺么?论坛里面很多人看一个代码,就“学习下”,学来学去还是没有长进。
Marky 2012-12-24
  • 打赏
  • 举报
回复
引用 11 楼 caozhy 的回复:
byte[] bytes = Regex.Matches(s, "[0-9a-fA-F]{2}").Cast<Match>().Select(x => (byte)Convert.ToInt16("0x" + x.Value, 16)).ToArray();
学习下
threenewbee 2012-12-24
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "4e135bb679f08fd1671f6c146e294ee5504f4f4e4e3a4e3bff0c662f5426201c5bd251ac201d4e0d80fd786e5b9a";
            byte[] bytes = Regex.Matches(s, "[0-9a-fA-F]{2}").Cast<Match>().Select(x => (byte)Convert.ToInt16("0x" + x.Value, 16)).ToArray();
            var result1 = System.Text.UnicodeEncoding.BigEndianUnicode.GetString(bytes, 0, bytes.Length);
            Console.WriteLine(result1);
        }
    }
}

threenewbee 2012-12-24
  • 打赏
  • 举报
回复
或者 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { byte[] bytes = { 0x4e, 0x13, 0x5b, 0xb6, 0x79, 0xf0, 0x8f, 0xd1, 0x67, 0x1f, 0x6c, 0x14, 0x6e, 0x29, 0x4e, 0xe5, 0x50, 0x4f, 0x4f, 0x4e, 0x4e, 0x3a, 0x4e, 0x3b, 0xff, 0x0c, 0x66 , 0x2f, 0x54, 0x26, 0x20, 0x1c, 0x5b, 0xd2, 0x51, 0xac, 0x20, 0x1d, 0x4e, 0x0d, 0x80, 0xfd, 0x78, 0x6e, 0x5b, 0x9a }; var result1 = System.Text.UnicodeEncoding.BigEndianUnicode.GetString(bytes, 0, bytes.Length); Console.WriteLine(result1); } } }
Marky 2012-12-24
  • 打赏
  • 举报
回复
引用 7 楼 renmms 的回复:
byte[] bytes = Encoding.BigEndianUnicode.GetBytes(unicode);
不是这么读成字节数组的,每2位转换成字节。。。
threenewbee 2012-12-24
  • 打赏
  • 举报
回复
对你无语了。

string unicode = "专家称近期气温以偏低为主,是否“寒冬”不能确定";
byte[] bytes = Encoding.BigEndianUnicode.GetBytes(unicode);
var result1 = System.Text.UnicodeEncoding.BigEndianUnicode.GetString(bytes, 0, bytes.Length);
renmms 2012-12-24
  • 打赏
  • 举报
回复
引用 6 楼 caozhy 的回复:
引用 5 楼 renmms 的回复:引用 4 楼 caozhy 的回复:string s = System.Text.Encoding.BigEndianUnicode.GetString(b); 我用什么编码转成byte数组呢? GBK? 不是告诉你了么,是BigEndianUnicode
string unicode = "4e135bb679f08fd1671f6c146e294ee5504f4f4e4e3a4e3bff0c662f5426201c5bd251ac201d4e0d80fd786e5b9a"; byte[] bytes = Encoding.BigEndianUnicode.GetBytes(unicode); var result1 = System.Text.UnicodeEncoding.BigEndianUnicode.GetString(bytes, 0, bytes.Length); 你看吧,不行
threenewbee 2012-12-24
  • 打赏
  • 举报
回复
引用 5 楼 renmms 的回复:
引用 4 楼 caozhy 的回复:string s = System.Text.Encoding.BigEndianUnicode.GetString(b); 我用什么编码转成byte数组呢? GBK?
不是告诉你了么,是BigEndianUnicode
renmms 2012-12-24
  • 打赏
  • 举报
回复
引用 4 楼 caozhy 的回复:
string s = System.Text.Encoding.BigEndianUnicode.GetString(b);
我用什么编码转成byte数组呢? GBK?
threenewbee 2012-12-24
  • 打赏
  • 举报
回复
string s = System.Text.Encoding.BigEndianUnicode.GetString(b);
renmms 2012-12-24
  • 打赏
  • 举报
回复
引用 2 楼 caozhy 的回复:
大端的Unicode编码。
请问怎么反转?我有unicode,想转成汉字
threenewbee 2012-12-24
  • 打赏
  • 举报
回复
大端的Unicode编码。
threenewbee 2012-12-24
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            byte[] b = System.Text.Encoding.BigEndianUnicode.GetBytes("专家称近期气温以偏低为主,是否“寒冬”不能确定");
            Console.WriteLine(string.Join("", b.Select(x => x.ToString("x").PadLeft(2, '0'))));
        }
    }
}
4e135bb679f08fd1671f6c146e294ee5504f4f4e4e3a4e3bff0c662f5426201c5bd251ac201d4e0d 80fd786e5b9a Press any key to continue . . .

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧