逸逸记事
逸逸记事

我的分类(专题)

首页(175)
儿子(9)
SIP技术(9)
Web2.0(12)
摄影和DVD(8)
软件开发随笔(18)
名古屋打工生活(11)
微软技术开发(47)
Java技术(12)
加拿大移民生活(20)
生活点滴(6)
第一份工作--上海贝尔(18)
完成项目(13)
回国后的生活(0)


最新日志
独行者
终于知道什么叫外包了
人生悲哀之事
水晶报表中显示动态图片
水晶报表中的简单参数设置
怀念下小黑
dotnet中的数据连接Timeout
老板的思路
又买房了
交通事故

最新回复
回复:独行者
回复:怀念下小黑
回复:老板的思路
回复:mjSip学习笔记
回复:老板的思路
回复:dotnet中的数据连接Timeo
回复:mjSip学习笔记
回复:交通事故
回复:交通事故
回复:又买房了

留言板

签写新留言

您好,很希望问您一个关于jain-sip
生活经历就是最大的财富,羡哦~
java的Web开发问题
回复:疑问
IT还不如妓女呢,呵呵
myjavaserver的空间
求助
您的子域名已开通

统计
blog名称:人在旅途
日志总数:175
评论数量:505
留言数量:13
访问次数:1671532
建立时间:2005年12月7日

链接

 

生命是过客,人在旅途。奶奶是信基督教的,没啥文化,却养育了四子二女,还带过九个孙辈。老人家对生命的看法就是“人都是客人,迟早要回去的。”就以《人在旅途》来纪念她。

 

«September 2025»
123456
78910111213
14151617181920
21222324252627
282930

公告
  本人上传的源程序中可能引用或使用了第三方的库或程序,也可能是修改了第三方的例程甚至是源程序.所以本人上传的源程序禁止在以单纯学习为目的的任何以外场合使用,不然如果引起任何版权问题,本人不负任何责任.




     本站首页    管理页面    写新日志    退出
调整中...
[Web2.0]一个很好的JavaScript的库--加解密,ZIP-UNZIP... 
人在旅途 发表于 2006/7/7 16:05:48

地址:高度な JavaScript 技集 列:sprintf函数:// printf.js - version 1.1.0 // // Copyright (C) 2000-2002 Masanao Izumo <iz@onicos.co.jp> // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // // SYNOPSIS: // printf("format", ...); // str = sprintf("format", ...); // // Chages: // 2002-02-04 Masanao Izumo <mo@goice.co.jp> // - Fixed bug about sprintf("%%") will return "%%". // - Evaluate undefined "%" argument. That is: // numerical value ===> 0 (%d, %x, %o, etc) // string value ===> '' (%s) // printf(format, ...); function printf() { document.write(va_sprintf(printf.arguments)); } // str = sprintf(format, ...); function sprintf() { return va_sprintf(sprintf.arguments); } function va_sprintf(args) { var ch; var value; var longflag; var ljust; var len, llen; var zpad; var p; var output; var format_index, arg_index; var argc, argv; var specin; var format; output = ''; format_index = 0; arg_index = 1; argv = args; argc = args.length; format = args[0]; while (format_index < format.length) { ch = format.substr(format_index++, 1); if (ch != '%' || format_index == format.length) { output += ch; } else { // ch == '%' ljust = len = zpad = longflag = 0; llen = -1; p = format_index; specin = true; while (specin) { ch = format.substr(format_index++, 1); switch(ch) { case '-': ljust = 1; continue; case '0': // set zero padding if len not set if(len == 0) zpad = 1; // FALLTHROUGH case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': len = len * 10 + parseInt(ch); continue; case '.': llen = len; len = 0; continue; case '*': if (arg_index < argc) len = parseInt(argv[arg_index++]); else len = 0; if (len < 0) { ljust = 1; len = -len; } continue; case 'l': longflag = 1; continue; case 'u': case 'U': if (arg_index < argc) { if (longflag) { value = parseInt(argv[arg_index++]); } else { value = parseInt(argv[arg_index++]); value %= 4294967296; } } else { value = 0; } output += _dopr_fmtnum(value, 10,0, ljust, len, zpad); break; case 'o': case 'O': if (arg_index < argc) { if (longflag) { value = parseInt(argv[arg_index++]); } else { value = parseInt(argv[arg_index++]); value %= 4294967296; } } else { value = 0; } output += _dopr_fmtnum(value, 8,0, ljust, len, zpad); break; case 'd': case 'D': if (arg_index < argc) { if (longflag) { value = parseInt(argv[arg_index++]); } else { value = parseInt(argv[arg_index++]); value %= 4294967296; } } else { value = 0; } output += _dopr_fmtnum(value, 10,1, ljust, len, zpad); break; case 'x': if (arg_index < argc) { if (longflag) { value = parseInt(argv[arg_index++]); } else { value = parseInt(argv[arg_index++]); value %= 4294967296; } } else { value = 0; } output += _dopr_fmtnum(value, 16,0, ljust, len, zpad); break; case 'X': if (arg_index < argc) { if (longflag) { value = parseInt(argv[arg_index++]); } else { value = parseInt(argv[arg_index++]); value %= 4294967296; } } else { value = 0; } output += _dopr_fmtnum(value, -16,0, ljust, len, zpad); break; case 's': if (arg_index < argc) { value = argv[arg_index++]; if(value == null) value = "(null)"; else value = value + ""; // toString } else { value = ''; } output += _dopr_fmtstr(value, ljust, len, llen); break; case 'c': if (arg_index < argc) { value = parseInt(argv[arg_index++]); } else { value = 0; } output += _dopr_fromCharCode(value); break; case '%': output += '%'; break; /* Not supported case 'f': case 'e': case 'E': case 'g': case 'G': if (arg_index < argc) { value = argv[arg_index++]; } else { value = 0.0; } output += _dopr_fmtdouble(format.substr(p, format_index - p), value); break; */ default: if(p + 1 == format_index) { output += '%'; output += ch; } else { // alert("format error: " + format); } break; } specin = false; } } } return output; } // Private function function _dopr_fmtnum(value, base, dosign, ljust, len, zpad) { var signvalue = ''; var uvalue; var place = 0; var padlen; // amount to pad var caps = 0; var convert; var output; convert = ''; output = ''; if(value >= 0) uvalue = value; else uvalue = (value % 4294967296) + 4294967296; if (dosign) { if (value < 0) { signvalue = '-'; uvalue = -value; } } if (base < 0) { caps = 1; base = -base; } if(uvalue == 0) { convert = '0'; place = 1; } else { while (uvalue) { if(caps) convert = '0123456789ABCDEF'.substr(uvalue % base, 1) + convert; else convert = '0123456789abcdef'.substr(uvalue % base, 1) + convert; uvalue = parseInt(uvalue / base); place++; } } padlen = len - place; if (padlen < 0) padlen = 0; if (ljust) padlen = -padlen; if (zpad && padlen > 0) { if(signvalue) { output += signvalue; --padlen; signvalue = 0; } while (padlen > 0) { output += '0'; --padlen; } } while (padlen > 0) { output += ' '; --padlen; } if (signvalue) { output += signvalue; } output += convert; while(padlen < 0) { output += ' '; ++padlen; } return output; } // Private function function _dopr_fmtstr(value, ljust, field_len, llen) { var padlen; // amount to pad var slen, truncstr = 0; var output = ''; slen = value.length; if (llen != -1) { var rlen; rlen = field_len; if (slen > rlen) { truncstr = 1; slen = rlen; } field_len = llen; } padlen = field_len - slen; if (padlen < 0) padlen = 0; if (ljust) padlen = -padlen; while (padlen > 0) { output += ' '; --padlen; } if (truncstr) { output += value.substr(0, slen); } else { output += value; } while (padlen < 0) { output += ' '; ++padlen; } return output; } // Private function var _dopr_fromCharCode_chars = null; function _dopr_fromCharCode(code) { if(String.fromCharCode) return String.fromCharCode(code); if(!_dopr_fromCharCode_chars) _dopr_fromCharCode_chars = "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020" + "\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !\"#$%&" + "'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghi" + "jklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211" + "\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232" + "\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253" + "\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274" + "\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315" + "\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336" + "\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357" + "\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"; if(code < 0) return ""; if(code <= 255) return _dopr_fromCharCode_chars.substr(code, 1); return eval(sprintf("\"\\u%04x\"", code)); }  

阅读全文(5423) | 回复(1) | 编辑 | 精华

回复:一个很好的JavaScript的库--加解密,ZIP-UNZIP...
WWWW(游客)发表评论于2010/1/22 2:44:34

这是啥啊

个人主页 | 引用回复 | 主人回复 | 返回 | 编辑 | 删除

» 1 »

发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)

站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.016 second(s), page refreshed 144783859 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号