代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace GB2312ConvertChinese
{
class Program
{
static void Main(string[] args)
{
string content = "/HTC Butterfly X920e是刚刚推出不久的一款智能手机,该机的5.0英寸大屏&";
Console.WriteLine(GBKToChinese(content));
Console.ReadKey();
}
static string GBKToChinese(string content)
{
string pattern = "&#(.+?);";
if (!Regex.IsMatch(content, pattern))
return content;
MatchCollection collection = Regex.Matches(content, pattern);
foreach (Match item in collection)
{
string GBK_Code = item.Value;
string GBK_Value = item.Groups[1].Value;
string chinese = ((char)Convert.T