资源简介
ASCII 及UTF-8 与字符互相转换

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace AsiccII
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender EventArgs e)
{
this.textBox2.Text = this.bytesConvertToString(this.textBox1.Text);
}
private string bytesConvertToString(string inputAsciiData)
{
#region just for Ascii
string strResult = ““;
if (inputAsciiData == null || inputAsciiData == ““)
{
strResult = ““;
}
else
{
if (inputAsciiData[0].ToString() == “^“)
{
string[] vAsciiDataSplitArray = inputAsciiData.Substring(1).Split(‘^‘);
byte[] vAsciiDataBatesArray = new byte[vAsciiDataSplitArray.Length];
for (int i = 0; i < vAsciiDataSplitArray.Length; i++)
vAsciiDataBatesArray[i] = Convert.ToByte(vAsciiDataSplitArray[i].ToString());
strResult = Encoding.UTF8.GetString(vAsciiDataBatesArray);
}
else
{
strResult = inputAsciiData;
}
}
return strResult;
#endregion
}
private void button2_Click(object sender EventArgs e)
{
this.textBox4.Text = this.UTF8Convert(this.textBox3.Text.Trim());
}
//private string StringToAscii(string s)
//{
// string ascii = ““;
// foreach (char c in s)
// {
// int sss = (int)c;
// ascii += “^“ + sss.ToString();
// }
// //if (ascii.Length > 0)
// //{
// // ascii = ascii.Substring(0 ascii.Length - 1);
// //}
// return ascii;
//}
private string UTF8Convert(string str)
{
if (str != ““)
{
byte[] t_byte = Encoding.UTF8.GetBytes(str);
string code = ““;
for (int i = 0; i < t_byte.Length; i++)
{
code += “^“ + t_byte[i].ToString();
}
return code;
}
else
return ““;
}
private string toUTF8(string str)
{
string returnStr = ““;
//汉字转成UTF-8十六进制码:
byte[] utf8 = Encoding.UTF8.GetBytes(str);
string s3 = ““;
//string s3d = ““;
foreach (byte b in utf8)
{
//s3 += Convert.ToString(b 16) + “ “;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-07-07 11:11 AsiccII\
目录 0 2014-07-07 11:11 AsiccII\AsiccII\
文件 863 2013-05-23 14:53 AsiccII\AsiccII.sln
文件 24064 2014-07-15 15:09 AsiccII\AsiccII.suo
文件 3673 2013-05-23 14:59 AsiccII\AsiccII\AsiccII.csproj
目录 0 2014-07-07 11:11 AsiccII\AsiccII\bin\
目录 0 2014-07-07 11:11 AsiccII\AsiccII\bin\Debug\
文件 10240 2013-06-03 08:24 AsiccII\AsiccII\bin\Debug\AsiccII.exe
文件 26112 2013-06-03 08:24 AsiccII\AsiccII\bin\Debug\AsiccII.pdb
文件 11600 2014-07-15 15:09 AsiccII\AsiccII\bin\Debug\AsiccII.vshost.exe
文件 490 2010-03-17 22:39 AsiccII\AsiccII\bin\Debug\AsiccII.vshost.exe.manifest
文件 3662 2013-06-03 08:28 AsiccII\AsiccII\Form1.cs
文件 4537 2013-06-03 08:24 AsiccII\AsiccII\Form1.Designer.cs
文件 5817 2013-06-03 08:24 AsiccII\AsiccII\Form1.resx
目录 0 2014-07-07 11:11 AsiccII\AsiccII\obj\
目录 0 2014-07-07 11:11 AsiccII\AsiccII\obj\x86\
目录 0 2014-07-07 11:11 AsiccII\AsiccII\obj\x86\Debug\
文件 1713 2014-07-15 15:09 AsiccII\AsiccII\obj\x86\Debug\AsiccII.csproj.FileListAbsolute.txt
文件 10240 2013-06-03 08:24 AsiccII\AsiccII\obj\x86\Debug\AsiccII.exe
文件 180 2013-06-03 08:24 AsiccII\AsiccII\obj\x86\Debug\AsiccII.Form1.resources
文件 26112 2013-06-03 08:24 AsiccII\AsiccII\obj\x86\Debug\AsiccII.pdb
文件 180 2013-05-30 11:43 AsiccII\AsiccII\obj\x86\Debug\AsiccII.Properties.Resources.resources
文件 4440 2013-05-30 13:32 AsiccII\AsiccII\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6211 2014-07-15 15:09 AsiccII\AsiccII\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 530 2013-06-03 08:24 AsiccII\AsiccII\obj\x86\Debug\GenerateResource.read.1.tlog
文件 1258 2013-06-03 08:24 AsiccII\AsiccII\obj\x86\Debug\GenerateResource.write.1.tlog
文件 7897 2013-05-30 14:05 AsiccII\AsiccII\obj\x86\Debug\ResolveAssemblyReference.cache
目录 0 2013-05-23 22:08 AsiccII\AsiccII\obj\x86\Debug\TempPE\
文件 499 2013-05-23 14:53 AsiccII\AsiccII\Program.cs
目录 0 2014-07-07 11:11 AsiccII\AsiccII\Properties\
文件 1434 2013-05-23 14:53 AsiccII\AsiccII\Properties\AssemblyInfo.cs
............此处省略4个文件信息
- 上一篇:16Qam源代码
- 下一篇:5ucms会员系统UTF8版
相关资源
- Fabrication and all-optical poling characteris
- vc 柱形图 CBarChart
- 常用编码(UnicodeUTF-8GBK)转换工具
- utf-8 ansi 字符互转 工具
- teechart 源代码
- 全自动多功能编码转换工具(URLASCI
- 十六进制与字符串互转
- 从EXCEL中取数据在Teechart7显示应用示例
- Effects of the cultured Cordyceps exopolysacch
- Synthesis Characterization and in vitro Antitu
- Novel fluorescent proteins generated by de nov
- TeeChart Pro ActiveX V5
- eCharts全国及各省、市、县地图层jso
- CChart与炫彩界面库联合编程演示代码
- MSChart使用手册
- labview ASCII_十六进制_十进制转换
- 用ATLAS探测器在s = 13TeV pp碰撞中用ta
- 在s = 13 $$ \\ sqrt {s} = 13 $$ TeV的质子-质
- Wavelet characterization for multipliers on So
- Strichartz estimates for the wave equation wit
- Echarts扩展百度地图
- echarts大数据可视化新能源车联网综合
- Characterization and Cytocompatibility of Nano
- Effects of L-type Matching Network on Characte
- An investigation into effects of Argon anneali
- UCS-2转换为utf-8代码
- Graph And Chart 1.91.unitypackage
- echart地图 34省js及json文件 344地级js
- 全国各省市地json图
- Echarts3.0地图
评论
共有 条评论