1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ToolsClassLibrary
- {
- /// <summary>
- /// 自定义编码转换 ASCII UTF_8
- /// </summary>
- public static class MyEncoding
- {
- /// <summary>
- /// 编码ASCII
- /// </summary>
- /// <param name="buf"></param>
- /// <returns></returns>
- public static byte[] EncodingASCII(string buf)
- {
- byte[] data = Encoding.Unicode.GetBytes(buf);
- return data;
- }
- /// <summary>
- /// 解码ASCII
- /// </summary>
- /// <param name="bt"></param>
- /// <returns></returns>
- public static string DecodingASCII(byte[] bt)
- {
- string st = Encoding.Unicode.GetString(bt);
- return st;
- }
- /// <summary>
- /// 编码UTF_8
- /// </summary>
- /// <param name="buf"></param>
- /// <returns></returns>
- public static byte[] EncodingUTF_8(string buf)
- {
- byte[] data = Encoding.UTF8.GetBytes(buf);
- return data;
- }
- /// <summary>
- /// 编码UTF_8
- /// </summary>
- /// <param name="bt"></param>
- /// <returns></returns>
- public static string DecodingUTF_8(byte[] bt)
- {
- string st = Encoding.UTF8.GetString(bt);
- return st;
- }
- }
- }
|