简单的乱码恢复工具源码
By
ztmdnike
at 2021-12-06 • 0人收藏 • 876人看过
简单的乱码恢复工具源码,测试还是有点问题,抛砖引玉,希望喜欢折腾的人再去修正一下,并且加一个排序功能等
import win.ui; /*DSG{{*/ var winform = win.form(text="乱码恢复查询工具";right=986;bottom=649) winform.add( btnSearch={cls="button";text="乱码恢复";left=870;top=11;right=964;bottom=50;db=1;dr=1;z=2}; listview={cls="listview";left=2;top=85;right=985;bottom=646;acceptfiles=1;bgcolor=16777215;db=1;dl=1;dr=1;dt=1;edge=1;fullRow=1;gridLines=1;msel=false;z=1}; plus={cls="plus";left=31;top=16;right=858;bottom=75;align="left";autohscroll=false;bgcolor=16777215;border={bottom=1;color=-6908266};edge=1;editable=1;font=LOGFONT(h=-13);forecolor=16777215;multiline=1;notify=1;textPadding={top=6;bottom=2};wrap=1;z=3} ) /*}}*/ winform.listview.insertColumn("当前源编码字符集",350); winform.listview.insertColumn("代码页",50,,0x2/*_LVCFMT_CENTER*/); winform.listview.insertColumn("转后目标编码字符集",350,,0x1/*_LVCFMT_RIGHT*/); winform.listview.insertColumn("代码页",50,,0x2/*_LVCFMT_CENTER*/); winform.listview.insertColumn("恢复结果",100,,0x2/*_LVCFMT_CENTER*/); winform.plus.setCueBannerText("请输入乱码的文本") import com.interface.IMultiLanguage2; var multiLanguage = com.interface.IMultiLanguage2.Create(); var tab={}; for( cpInfo in multiLanguage.eachCodepage() ){ table.push(tab,{cpInfo.webCharset+" "+cpInfo.description;cpInfo.uiCodePage}) } winform.listview.adjust = function(cx,cy){ winform.listview.fillParent(5); } winform.btnSearch.oncommand = function(id,event){ var txt=winform.plus.text; if txt="" return ; winform.listview.clear() winform.btnSearch.disabled=true; thread.invoke( function(tab,winform,txt){ import com.interface.IMultiLanguage2; var mlang = com.interface.IMultiLanguage2.Create(); for(i=1;#tab;1){ for(k=1;#tab;1){ if tab[i][2]==tab[k][2] continue; var a,b,str=tonumber('-'+tab[i][2]),tonumber('-'+tab[k][2]) try{ str=mlang.fromto(txt,a,b); } catch(e){ str=null; } if str=null continue; str=..string.replace(str,"?",""); str=..string.replace(str,"o",""); str=..string.trim(str,'\x00') str=..string.trim(str) if str="" continue; winform.listview.addItem({ tab[i][1]; tab[i][2]; tab[k][1]; tab[k][2]; str }) } } winform.btnSearch.disabled=false; },tab,winform,txt ) } winform.show() win.loopMessage();
2 个回复 | 最后更新于 2021-12-06
登录后方可回帖