java utf8 to gb2312_utf-8编码转换成gb2312

utf-8编码转换成gb2312

更新时间:2006年09月23日 00:00:00   作者:

[code]

function  chinesefromutf8url(strutf8)

{

var  bstr  =  "";

var  noffset  =  0;

//  processing  point  on  strutf8

if(  strutf8  ==  ""  )

return  "";

strutf8  =  strutf8.tolowercase();

noffset  =  strutf8.indexof("%e");

if(  noffset  ==  -1  )

return  strutf8;

while(  noffset  !=  -1  )

{

bstr  +=  strutf8.substr(0,  noffset);

strutf8  =  strutf8.substr(noffset,  strutf8.length  -  noffset);

if(  strutf8  ==  ""    ¦  ¦  strutf8.length  

return  bstr;

bstr  +=  utf8codetochinesechar(strutf8.substr(0,  9));

strutf8  =  strutf8.substr(9,  strutf8.length  -  9);

noffset  =  strutf8.indexof("%e");

}

return  bstr  +  strutf8;

}

function  unicodefromutf8(strutf8)

{

var  bstr  =  "";

var  ntotalchars  =  strutf8.length;            //  total  chars  to  be  processed.

var  noffset  =  0;                                                            //  processing  point  on  strutf8

var  nremainingbytes  =  ntotalchars;            //  how  many  bytes  left  to  be  converted

var  noutputposition  =  0;

var  icode,  icode1,  icode2;                                    //  the  value  of  the  unicode.

while  (noffset  

{

icode  =  strutf8.charcodeat(noffset);

if  ((icode  &  0x80)  ==  0)                                    //  1  byte.

{

if  (  nremainingbytes  

break;

bstr  +=  string.fromcharcode(icode  &  0x7f);

noffset  ++;

nremainingbytes  -=  1;

}

else  if  ((icode  &  0xe0)  ==  0xc0)            //  2  bytes

{

icode1  =    strutf8.charcodeat(noffset  +  1);

if  (  nremainingbytes  

(icode1  &  0xc0)  !=  0x80  )                        //  invalid  pattern

{

break;

}

bstr  +=  string.fromcharcode(((icode  &  0x3f)  <

noffset  +=  2;

nremainingbytes  -=  2;

}

else  if  ((icode  &  0xf0)  ==  0xe0)            //  3  bytes

{

icode1  =    strutf8.charcodeat(noffset  +  1);

icode2  =    strutf8.charcodeat(noffset  +  2);

if  (  nremainingbytes  

(icode1  &  0xc0)  !=  0x80    ¦  ¦                        //  invalid  pattern

(icode2  &  0xc0)  !=  0x80  )

{

break;

}

bstr  +=  string.fromcharcode(((icode  &  0x0f)  <

((icode1  &  0x3f)  <

(icode2  &  0x3f));

noffset  +=  3;

nremainingbytes  -=  3;

}

else                                                                                                //  4  or  more  bytes  --  unsupported

break;

}

if  (nremainingbytes  !=  0)

{

//  bad  utf8  string.

return  "";

}

return  bstr;

}

function  utf8codetochinesechar(strutf8)

{

var  icode,  icode1,  icode2;

icode  =  parseint("0x"  +  strutf8.substr(1,  2));

icode1  =  parseint("0x"  +  strutf8.substr(4,  2));

icode2  =  parseint("0x"  +  strutf8.substr(7,  2));

return  string.fromcharcode(((icode  &  0x0f)  <

((icode1  &  0x3f)  <

(icode2  &  0x3f));

}

alert(chinesefromutf8url("%e6%b5%8b%e8%af%95"))

[code]

相关文章

1a1b05c64693fbf380aa1344a7812747.png

这篇文章主要介绍了对象不支持此属性或方法: Session.CodePage = 936 解决方法,需要的朋友可以参考下2015-07-07

4f55910a645b073bc4fc65dc10dc14bd.png

asp创建访问统计代码,实例2008-10-10

0ea3c7666119d5615e582f823fb3fad6.png

在asp中,我们可以用response.cookies方法,定义cookies的值。2010-03-03

4f96a78db829b1556ff16de21e013c7a.png

在ASP编程中使用数组...2006-10-10

8cc1031babc6aff2319f1c6af8544aa0.png

个人网站如有会员注册模块+动网论坛的话,那网站要与动网论坛系统整合,实现不同Web系统之间的用户信息同步更新、登录等操作就不是件容易的事了2008-06-06

0c932a99bb7b6f23c937db507070cc7b.png

抓取网页。偶要实现实实更新天气预报。利用了XMLHTTP组件,抓取网页的指定部分,其实很多的小偷程序要更好用2012-10-10

cca732bf65a93ed2ec0ac80c638460fe.png

这篇文章主要介绍了ASP模仿google suggest风格实现下拉菜单效果,需要的朋友可以参考下2015-09-09

2d9f31f2af7b675a3d153d2b7f1035a7.png

获取当前月份距离以前某个时间的月份数,asp都是用DateDiff函数来实现2012-04-04

b452cee8ec5cd9e58ab98eba17281e59.png

NextRecordset 和 GetRows 双簧合奏...2006-09-09

f4838ec7e2d4da28e0b57d4e852dadd4.png

利用ActiveX控件InetCtls.Inet在ASP中实现新闻小偷...2007-02-02

最新评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
系统根据B/S,即所谓的电脑浏览器/网络服务器方式,运用Java技术性,挑选MySQL作为后台系统。系统主要包含对客服聊天管理、字典表管理、公告信息管理、金融工具管理、金融工具收藏管理、金融工具银行卡管理、借款管理、理财产品管理、理财产品收藏管理、理财产品银行卡管理、理财银行卡信息管理、银行卡管理、存款管理、银行卡记录管理、取款管理、转账管理、用户管理、员工管理等功能模块。 文中重点介绍了银行管理的专业技术发展背景和发展状况,随后遵照软件传统式研发流程,最先挑选适用思维和语言软件开发平台,依据需求分析报告模块和设计数据库结构,再根据系统功能模块的设计制作系统功能模块图、流程表和E-R图。随后设计架构以及编写代码,并实现系统能模块。最终基本完成系统检测和功能测试。结果显示,该系统能够实现所需要的作用,工作状态没有明显缺陷。 系统登录功能是程序必不可少的功能,在登录页面必填的数据有两项,一项就是账号,另一项数据就是密码,当管理员正确填写并提交这二者数据之后,管理员就可以进入系统后台功能操作区。进入银行卡列表,管理员可以进行查看列表、模糊搜索以及相关维护等操作。用户进入系统可以查看公告和模糊搜索公告信息、也可以进行公告维护操作。理财产品管理页面,管理员可以进行查看列表、模糊搜索以及相关维护等操作。产品类型管理页面,此页面提供给管理员的功能有:新增产品类型,修改产品类型,删除产品类型。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值