前往Shuct.Net首页

Shudepb PB反编译专家长时间以来,为业内同类软件事实上的唯一选择.细节,彰显专业.态度,决定品质.

关于PowerBuilder的搜索

PowerBuilder对字符串、网址的编码转换(编码、解码) 加入收藏 | 网站地图 | | RSS | WAP 你好,游客 登录 注册 搜索 我们一直在努力! 业界 互联网资讯 软件资讯 人物资讯 网页 Dreamweaver Flash教程 CSS教程 平面 Photoshop Fireworks CorelDraw 多媒体 3DMax教程 Maya教程 Premiere 程序 ASP教程 PHP教程 .NET教程 数据库 Access教程 SQL Server MySQL教程 办公 Word教程 Excel教程 WPS教程 工具 聊天工具 影音工具 浏览器 服务器 Web服务器 Ftp服务器 Mail服务器 系统 Windows XP Windows 7 Vista教程 网络 局域网组建 局域网管理 无线应用 安全 基础知识 安全防范 防火墙 站长 推广宣传 SEO优化 免费资源 认证 系统管理 软件开发 数据库管理 壁纸 明星壁纸 动漫壁纸 游戏壁纸 首页业界网页平面多媒体程序数据库办公工具服务器系统网络安全站长认证壁纸 位置:首页 > 程序 > PowerBuilder教程 背景: 阅读内容 领跑条码、标签打印软件 | 来电弹出客户资料 PowerBuilder对字符串、网址的编码转换(编码、解码) [日期:2012-09-25] 作者: 来源: [字体:大 中 小] --> 环境:PB12 函数实现: public function string urlencode (character as_text[], encoding ae_encode);//对中文字符进行url 编码 //参数1:要编码的字符串 //参数2:要以哪种字符集编码 char lc_ret[] string ls_ret int i,j,li_len string ls_temp for i=1 to upperbound(as_text) if asc(as_text[i])>19968 then ls_temp=hexencode(as_text[i],ae_encode) li_len=len(ls_temp) li_len=li_len + li_len / 2 //增加百分号以后长度会增加1/2 for j=1 to li_len step 3 ls_temp=replace(ls_temp,j,0,'%') next else ls_temp=as_text[i] end if ls_ret+=ls_temp next return ls_ret end function public function string urldecode (character as_text[], encoding ae_encode);//对中文字符进行url 解码 //参数1:要解码的字符串 //参数2:要以哪种字符集解码 string ls_ret int i string ls_str1 for i=1 to upperbound(as_text) if as_text[i]='%' then ls_str1+=as_text[i + 1]+as_text[i + 2] i=i + 2 else if ls_str1>'' then ls_ret+=hexdecode(ls_str1,ae_encode) ls_str1='' end if ls_ret=ls_ret+as_text[i] end if next if ls_str1>'' then ls_ret+=hexdecode(ls_str1,ae_encode) end if return ls_ret end function public function string hexdecode (character ac_text[], encoding ae_encode);//将字符串指定字符集进行编码成16进制字符串 int i byte lb_byte[] blob lb_blob char ls_result[] u_derek_fun u_fun //用户对象其中todec 是其它进制转10进制的函数 for i=1 to upperbound(ac_text) / 2 lb_byte[i]=u_fun.todec(ac_text[2 * i - 1]+ac_text[2 * i],16) next lb_blob=blob(lb_byte) ls_result=string(lb_blob,ae_encode) return ls_result[] ////PB9 // //int i //char lc_ret[] //for i=1 to upperbound(ac_text) / 2 // lc_ret[i]=charA(todec(ac_text[2 * i - 1]+ac_text[2 * i],16)) //next //clipboard(lc_ret) //return lc_ret end function 函数说明: 例:ANSI的CFC4-->"夏"utf8的E5 A4 8F-->"夏"hexencode 将字符串指定字符集进行编码成16进制字符串例:ANSI的"夏"-->CFC4utf8的"夏"-->E5 A4 8Furldecode 将指定字符串以进行指定字符集url解码例:ANSI的"http://runsa.cn/?uid=a夏"-->http://runsa.cn/?uid=a%CF%C4utf8的"http://runsa.cn/?uid=a夏"-->http://runsa.cn/?uid=a%E5%A4%8Furlencode 将指定字符串以进行指定字符集url编码 例:ANSI的"a'>http://runsa.cn/?uid=a%CF%C4-->http://runsa.cn/?uid=a夏utf8的"a'>http://runsa.cn/?uid=a%E5%A4%8F-->http://runsa.cn/?uid=a夏 public function decimal todec (string as_num, decimal ad_sys);//其它进制转10进制数字函数 //参数1:要转换的数字 //参数2:源进制 //说明:ad_sys只能为整数 dec ld_num,ld_num1 string ls_num1 int i,li_sign=1 int li_pos,li_len,li_pointpos,li_maxpower,li_minpower if isnull(as_num) or isnull(ad_sys) then return 0 if dec(as_num)<0 then //是负数 li_sign=-1 as_num=mid(as_num,1) //去除负号 end if li_len=len(as_num) if li_len=1 then if as_num>'9' then //如果是字符 ld_num=asc(as_num) - 64 + 9 else ld_num=dec(as_num) end if else li_pointpos=pos(as_num,'.') //点的位置 if li_pointpos=0 then li_maxpower=li_len - 1 li_minpower=0 else li_maxpower=li_pointpos - 2 li_minpower= li_pointpos - li_len end if li_pos=1 for i=li_maxpower to li_minpower step -1 if li_pos=li_pointpos then //位置到点的位置 i ++ else ls_num1=mid(as_num,li_pos,1) ld_num1=todec(ls_num1,ad_sys) ld_num=ld_num + (ld_num1 * (ad_sys^i) ) end if li_pos++ //位置加1 next end if return ld_num * li_sign end function public function string hexstring (string as_text, readonly encoding ae_encode);//将字符转换成16进制编码 //参数1:是要转换的字符 //参数2:源字符中编码 //返回16进制编码 return hexencode(as_text,ae_encode) end function public function string decto (decimal ad_dec, readonly unsignedinteger aui_sys);//作用:将十进制数字转成其它进制字符串 //参数1:十进制数字 //参数2:目标进制 string ls_ret //返回的结果 string ls_dec string ls_left,ls_right,ls_mod uint ld_mod /*余数为整数*/ dec ld_mul //取小数的乘积为dec int i,li_pos,li_len,li_pointpos,li_maxpower,li_minpower if isnull(ad_dec) or isnull(aui_sys) or aui_sys<2 then goto e ls_dec=string(ad_dec) li_pointpos=pos(ls_dec,'.') if li_pointpos=0 then if ad_dec<aui_sys then //大于10进制 if ad_dec<=9 then ls_ret=string(ad_dec) goto e elseif ad_dec>9 and ad_dec<aui_sys then ls_ret=char(64 - 9 + ad_dec) //大于9的数字为转换为字母 goto e end if else do ld_mod=mod(ad_dec,aui_sys) //取余数 ls_mod=decto(ld_mod,aui_sys) ls_ret=ls_mod+ls_ret ad_dec=long(( ad_dec - ld_mod) / aui_sys ) //去余取商 loop until ad_dec<aui_sys if ad_dec>9 then ls_ret=char(64 - 9 + ad_dec)+ls_ret else ls_ret=string(ad_dec)+ls_ret end if end if else ls_left=mid(ls_dec,1,li_pointpos) //取整数 ls_right=mid(ls_dec,li_pointpos) //取小数 ls_ret=decto(dec(ls_left),aui_sys)+'.' //整数部分转换 ld_mul=dec(ls_right) for i=1 to 10 //最大精度为10 ld_mul=ld_mul * aui_sys ls_ret=ls_ret+string(int(ld_mul)) //取整 if ld_mul=int(ld_mul) then exit //没有余数 ld_mul=ld_mul - int(ld_mul) //去除整数 next end if e: return ls_ret end function public function string hexencode (string as_text, readonly encoding ae_encode);//将字符转换成16进制编码 //参数1:是要转换的字符 //参数2:源字符中编码 //返回16进制编码 blob lb_text blob{100} lb_stext string ls_text2,ls_ret,ls_str1 uint i,li_len,li_asc string ls_hex //ls_text2=space(100) //转换成编码encodingutf16BE if len(as_text)<=50 then lb_stext=blob(as_text,ae_encode) ls_text2=string(lb_stext,encodingutf16Be!) else lb_text=blob(as_text,ae_encode) ls_text2=string(lb_text,encodingutf16Be!) end if li_len=len(ls_text2) for i=1 to li_len ls_str1=mid(ls_text2,i,1) li_asc=asc(ls_str1) ls_hex=decto(li_asc,16) //// if ae_encode=encodingutf16BE! then //高尾 ls_hex=fill('0',4 - len(ls_hex))+ls_hex ls_ret=ls_ret+ls_hex elseif ae_encode=encodingutf16lE! then //低尾 ls_hex=fill('0',4 - len(ls_hex))+ls_hex ls_ret=ls_ret+ls_hex else if right(ls_hex,2)='00' then ls_hex=left(ls_hex,2) ls_ret=ls_ret+ls_hex end if next return ls_ret end function 函数介绍: decto 将十进制数字转成其它进制字符串(支持小数位)例:将十进制换成二进制 2-->10todec 将指定进制的数字转换成10进制(支持小数位)例:将二进制换成十进制 10-->2hexdecode 将16进制字符串以指定字符集进行解码成字符 关键词:字符串 转换 编码 网址 解码 0 顶一下 收藏 推荐 打印 | 录入:blue1000 | 阅读: 次 PowerBuilder十进制、二进制、十六进制转换(支持小数位) 最新图文 本文评论   查看全部评论 (0) 表情: 姓名: 匿名 字数 点评:    同意评论声明    发表 评论声明 尊重网上道德,遵守中华人民共和国的各项有关法律法规 承担一切因您的行为而直接或间接导致的民事/刑事法律责任 本站管理人员有权保留或删除其管辖留言中的任意内容 本站有权在网站内转载或引用您的评论 参与本评论即表明您已经阅读并接受上述条款 你还可能关注… java错误:无法将Object转换为int类型 java经典试题:字符串按照首字母排序 C#中转换函数Convert、Parse、TryParse、(int) C#获取当前输出设备中各种长度单位与像素之间的 SQLServer中日期与字符串之间的互相转换及日期 VB中各进制之间相互转换的函数 C#如何将对象转换为DataTable? C#中像素与毫米之间的转换 Digg排行 0PowerBuilder对字符串、网址的编码转换(编 0PowerBuilder十进制、二进制、十六进制转换 本周热门内容 PowerBuilder对字符串、网址的编码转换(编码、 PowerBuilder十进制、二进制、十六进制转换(支 站内搜索 网站地图 友情链接 免责声明 广告服务 联系我们 关于我们 Copyright&copy; 2003-2012 blue1000.com All Rights Reserved. 备案许可证号:豫ICP备11031112号 版权所有:BK网络学院本站部分图文内容取自互联网,若侵犯到您的著作权,请及时告知,我们将在第一时间删除侵权作品、并停止继续传播本站提倡网络资源免费共享、繁荣网络文化、促进网络和谐发展