码迷,mamicode.com
首页 > Windows程序 > 详细

C# 汉子增加UTF-8头

时间:2015-05-07 16:17:52      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConvertToUtf8
{
    public class ClassFun
    {
        public static byte[] Pathology_ConvertToBinary(string source)
        {
            byte[] utf8Prefix = Encoding.UTF8.GetPreamble();
            byte[] utf8Content = System.Text.Encoding.UTF8.GetBytes(source);
            byte[] NewUtf8Content = new byte[utf8Prefix.Length + utf8Content.Length];
            int NewUtf8ContentCount = 0;
            for (int i = 0; i < utf8Prefix.Length; i++)
            {
                NewUtf8Content[NewUtf8ContentCount] = utf8Prefix[i];
                NewUtf8ContentCount++;
            }
            for (int j = 0; j < utf8Content.Length; j++)
            {
                NewUtf8Content[NewUtf8ContentCount] = utf8Content[j];
                NewUtf8ContentCount++;
            }

            return NewUtf8Content;
        }
    }
}

 

C# 汉子增加UTF-8头

标签:

原文地址:http://www.cnblogs.com/cangowu/p/4484756.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!