1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > 怎样将英文html文件转换成中文 如何在html文件中修改文本中的英文文字为中文?源代码

怎样将英文html文件转换成中文 如何在html文件中修改文本中的英文文字为中文?源代码

时间:2023-01-02 21:04:54

相关推荐

怎样将英文html文件转换成中文 如何在html文件中修改文本中的英文文字为中文?源代码

/*lzw就是通过建立一个字符串表,用较短的代码来表示较长的字符串来实现压缩*/

#include

#include

#include

#include//用来计算压缩的时间

using namespace std;

//定义常数

const int max = 1000003;//最大code数,是一个素数,求模是速度比较快

const int ascii = 256; //ascii代码的数量

const int bytesize = 8; //8个字节

struct element//hash表中的元素

{

int key;

int code;

element *next;

}*table[max];//hash表

int hashfunction(int key)//hash函数

{

return key%max;

}

void hashinit(void)//hash表初始化

{

memset(table,0,sizeof(table));

}

void hashinsert(element element)//hash表的插入

{

int k = hashfunction(element.key);

if(table[k]!=null)

{

element *e=table[k];

while(e->next!=null)

{

e=e->next;

}

e->next=new element;

e=e->next;

e->key = element.key;

e->code = element.code;

e->next = null;

}

else

{

table[k]=new element;

table[k]->key = element.key;

table[k]->code = element.code;

table[k]->next = null;

}

}

bool hashfind(int key,element &element)//hash表的查找

{

int k = hashfunction(key);

if(table[k]!=null)

{

element *e=table[k];

while(e!=null)

{

if(e->key == key)

{

element.key = e->key;

element.code = e->code;

return true;

}

e=e->next;

}

return false;

}

else

{

return false;

}

}

void compress(void)//压缩程序

{

//打开一个流供写入

file *fp;

fp = fopen("result.dat", "wb");

element element;

int used;

char c;

int pcode, k;

for(int i=0;i

{

element.key = i;

element.code = i;

hashinsert(element);

}

used = ascii;

c = getchar();

pcode = c;

while((c = getchar()) != eof)

{

k = (pcode << bytesize) + c;

if(hashfind(k, element))

pcode = element.code;

else

{

//cout<

fwrite(&pcode, sizeof(pcode), 1, fp);

element.code = used++;

element.key = (pcode << bytesize) | c;

hashinsert(element);

pcode = c;

}

}

//cout<

fwrite(&pcode, sizeof(pcode), 1, fp);

}

int main(void)

{

int t1,t2;

//欲压缩的文本文件

char xx[100]={0};

printf("请输入要压缩的文件:");

gets(xx);

freopen(xx,"r",stdin);

t1=time(null);

hashinit();

compress();

t2=time(null);

cout<

cout<

}

怎样将英文html文件转换成中文 如何在html文件中修改文本中的英文文字为中文?源代码识别不了...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。