Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12470484
  • 博文数量: 1293
  • 博客积分: 13501
  • 博客等级: 上将
  • 技术积分: 17974
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 18:11
文章分类

全部博文(1293)

文章存档

2019年(1)

2018年(1)

2016年(118)

2015年(257)

2014年(128)

2013年(222)

2012年(229)

2011年(337)

分类: C#/.net

2016-06-29 16:41:01


  1.         public static string ByteArray2String(byte[] contentByte)
  2.         {
  3.             string result = string.Empty;
  4.             if(contentByte != null)
  5.                 result = Encoding.GetEncoding("UTF-8").GetString(contentByte, 0, contentByte.Length);

  6.             return result;
  7.         }


  8.         public static byte[] String2ByteArray(string documentText)//(Editor myEditor)
  9.         {
  10.             byte[] contentBytes = null;

  11.             /*!!! myEditor.Html中的IMAGE是路径,BodyHtml中的是转换后byte[],但bodyhtml只包含body内的html,
  12.              取整个文件的html需要使用DocumentText */
  13.             if (string.IsNullOrWhiteSpace(documentText))
  14.                 contentBytes = null;
  15.             else
  16.                 contentBytes = Encoding.GetEncoding("UTF-8").GetBytes(documentText);

  17.             return contentBytes;
  18.         }

阅读(3574) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~