文字输入转换
来源:互联网 发布:2016人口老龄化数据 编辑:程序博客网 时间:2024/04/30 14:21
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Text;
using System.IO;
namespace changeinput1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class changeinput
{
public changeinput()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public string zhuanhuan(string zs)
{
Encoding asc = Encoding.ASCII;
bool tag=false;
byte[] b=new byte[]{};
string s=kongge1(zs);
StringBuilder sb=new StringBuilder(s);
char[] ch=new char[]{};
ch=s.ToCharArray();
b=asc.GetBytes(ch,0,ch.Length);
int tempi=0;
int start=0;
int length=0;
string temps="";
string temps1="";
string temps2="";
string[] result=new string[]{};
for(int i=0;i<=ch.Length-1;i++)
{
if((b[i]==10))//当是"/n"时处理
{
tag=true;
if(b[i-2]==10)
{
temps1="<BR>";
temps2=temps2+temps1;
}
else
{
tempi=i;
length=i-start-1;
temps=s.Substring(start,length);
temps1=kongge(temps)+"<BR>";//处理空格
temps2=temps2+temps1;
start=tempi+1;
}
// Page.Response.Write(temps1);
// Page.Response.Write("<BR>");
temps1="";
}
}
if(!tag)//当字符中没有换行,既只有一行
{
temps2=kongge(s);
// Page.Response.Write(temps1);
// Page.Response.Write("<BR>");
}
return temps2;
}
public string kongge1(string s)//处理文字中的"/t"
{
string re="";
int tempi=0;
int start=0;
int length=0;
string temps="";
Encoding asc = Encoding.ASCII;
byte[] b=new byte[]{};
char[] ch=new char[]{};
char[] ch1=new char[]{};
string k=" ";
ch=s.ToCharArray();
b=asc.GetBytes(ch,0,ch.Length);
if(b[b.Length-1]!=10)//如果最后一个字符不是/n
{
s=s+"/r/n";
}
ch=s.ToCharArray();
b=asc.GetBytes(ch,0,ch.Length);
for(int i=0;i<=b.Length-1;i++)
{
if(b[i]==9)
{
re=re+k;
start=i+1;
}
else
{
length=1;
temps=s.Substring(start,length);
tempi=i;
start=tempi+1;
re=re+temps;
}
}
return re;
}
public string kongge(string s)//处理空格
{
string temps1="";
for(int k=0;k<=s.Length-1;k++)
{
if(k==s.Length-1)//最后一个字符
{
string s1=s.Substring(k);
if(String.Compare(s1," ")==0)
{
temps1=temps1+" ";
}
else
temps1=temps1+s1;
}
else
{
string s2=s.Substring(k, 1);
if(String.Compare(s2," ")==0)
{
temps1=temps1+" ";
}
else
temps1=temps1+s2;
}
}
return temps1;
}
}
}
- 文字输入转换
- 文字转换
- 输入框里有文字提示
- HtmlInputText 文字输入盒
- 常用粤语文字输入
- Excel文字输入技巧
- Excel文字输入技巧
- EditText限制文字输入
- 显示文字与输入
- cocos2dx之文字输入
- UITextView输入属性文字
- 沿路径输入文字
- php 限制输入文字
- 自动化测试输入文字
- InputConnection模拟文字输入
- 简繁体文字转换工具
- ASCII码转换文字
- 图片文字快速转换
- 非常棒的纯C++写的IDE:CodeBlocks; Suse 93安装过程
- 相对路径产生js文件、html文件。
- Testing First!
- Win32应用程序的加载与启动分析
- (翻译)测试Web Application之一:准备团队
- 文字输入转换
- WOW性格转变
- Installing FreeBSD 5
- 一个txt转htm的小程序
- datatool
- 脚本与WSH在网马中的初级应用
- 中文版windows终端服务小BUG
- 用自定义标签库和Validation验证表单
- 安装sql server遇到的content: Command line option syntax error. Type Command /? for Help.