此文版权属于作者智勇,任何人、媒体或者网站转载、借用都必须征得作者本人同意
<script type="text/javascript"> </script>
源码如下:
<
script type
=
"
text/javascript
"
>
function copyToClipboard(s)
... {
if( window.clipboardData && clipboardData.setData )
clipboardData.setData("Text", s);
}
function c2hex(c) ... {
var ss = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', '.'];
var res = "";
while(c>0)...{
res = ss[c%16] + res;
c >>= 4;
}
return res;
}
function i2desc(c) ... {
c = c%256;
var res = String.fromCharCode(c)
+ "(" + c
+ " 0x" + c2hex(c) + ")";
return res;
}
function String2HexString(s)
... {
var d = "";
for(var i = 0, c = s.length; i < c; i++)
d += c2hex(s.charCodeAt(i)) + " ";
return d;
}
function OnUserStrKeyUp() ... {
document.getElementById('hexstr_monk').innerHTML =
String2HexString(document.getElementById('user_str_monk').value);
}
var asc_table = " <table style='border:solid 1px #000; border-collapse:collapse;'> " ;
var c1 = " background-color:#fef " ;
var c2 = " background-color:#eff " ;
for ( var i = 1 ; i < 256 ; ++ i) ... {
if(i%16 == 1)
asc_table += "<tr>";
asc_table += "<td style='"
+ (i%2==1 ? (parseInt(i/16)%2 == 0 ? c1 : c2) : (parseInt(i/16)%2 == 0 ? c2 : c1))
+ "; text-align:center; border-right:solid 1px #ddd; border-top:solid 0px; border-bottom:solid 1px; #444; font-size:24px; cursor:hand"
+ "' title='"
+ i2desc(i)
+ "' οnclick='copyToClipboard("" + String.fromCharCode(i) + "");'>"
+ String.fromCharCode(i)
+ "</td>";
if(i%16 == 0)
asc_table += "</tr>";
}
if (i % 16 != 0 )
asc_table += " </tr> " ;
asc_table += " </table> " ;
document.write( " <h4>String To Hex String</h4> " );
document.write( " <input id='user_str_monk' οnkeyup='OnUserStrKeyUp(); return true;' style='WIDTH: 80%' value='智勇软件' /> " );
document.write( " <p id='hexstr_monk' style='background-color:f0fff0; WIDTH: 80%'>667A 52C7 8F6F 4EF6</p> " );
document.write( " <h4>ASC Table</h4> " );
document.write(asc_table);
if ( window.clipboardData && clipboardData.setData )
document.write( " <span style='font-size:12px; color:#8b8'>Click the char, than the char will be copied to the Clipboard!</span> " );
</ script >
function copyToClipboard(s)
... {
if( window.clipboardData && clipboardData.setData )
clipboardData.setData("Text", s);
}
function c2hex(c) ... {
var ss = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', '.'];
var res = "";
while(c>0)...{
res = ss[c%16] + res;
c >>= 4;
}
return res;
}
function i2desc(c) ... {
c = c%256;
var res = String.fromCharCode(c)
+ "(" + c
+ " 0x" + c2hex(c) + ")";
return res;
}
function String2HexString(s)
... {
var d = "";
for(var i = 0, c = s.length; i < c; i++)
d += c2hex(s.charCodeAt(i)) + " ";
return d;
}
function OnUserStrKeyUp() ... {
document.getElementById('hexstr_monk').innerHTML =
String2HexString(document.getElementById('user_str_monk').value);
}
var asc_table = " <table style='border:solid 1px #000; border-collapse:collapse;'> " ;
var c1 = " background-color:#fef " ;
var c2 = " background-color:#eff " ;
for ( var i = 1 ; i < 256 ; ++ i) ... {
if(i%16 == 1)
asc_table += "<tr>";
asc_table += "<td style='"
+ (i%2==1 ? (parseInt(i/16)%2 == 0 ? c1 : c2) : (parseInt(i/16)%2 == 0 ? c2 : c1))
+ "; text-align:center; border-right:solid 1px #ddd; border-top:solid 0px; border-bottom:solid 1px; #444; font-size:24px; cursor:hand"
+ "' title='"
+ i2desc(i)
+ "' οnclick='copyToClipboard("" + String.fromCharCode(i) + "");'>"
+ String.fromCharCode(i)
+ "</td>";
if(i%16 == 0)
asc_table += "</tr>";
}
if (i % 16 != 0 )
asc_table += " </tr> " ;
asc_table += " </table> " ;
document.write( " <h4>String To Hex String</h4> " );
document.write( " <input id='user_str_monk' οnkeyup='OnUserStrKeyUp(); return true;' style='WIDTH: 80%' value='智勇软件' /> " );
document.write( " <p id='hexstr_monk' style='background-color:f0fff0; WIDTH: 80%'>667A 52C7 8F6F 4EF6</p> " );
document.write( " <h4>ASC Table</h4> " );
document.write(asc_table);
if ( window.clipboardData && clipboardData.setData )
document.write( " <span style='font-size:12px; color:#8b8'>Click the char, than the char will be copied to the Clipboard!</span> " );
</ script >