Newsgroup: it.comp.lang.javascript
Titolo: conversione text

Ho trovato in rete questo script,
che vorrei modificare in questo modo:
vorrei che al posto di ad esempio
mycarii[53] = "0"; myaskii[53] = "&#48;"
poter mettere
mycarii[53] = "74"; myaskii[53] = "a"
però non me lo consente, in quanto converte
un numero per volta e nel mio caso avrei bisogno
di convertire due numeri alla volta, del tipo:
mycarii[53] = "74"; myaskii[53] = "a"
mycarii[54] = "75"; myaskii[53] = "b"
mycarii[55] = "76"; myaskii[53] = "c"
mycarii[56] = "77"; myaskii[53] = "d"
come posso modificarlo??
Hito.
<script language="javascript">
<!--
//test for various browsers
var browsertype = "IE4x"
if (document.all){browsertype = "IE4x"}else{}
if (document.layers){browsertype = "NN4x"}else{}
if (navigator.appVersion.indexOf("MSIE 5", 0) != -1){browsertype =
"IE5xDOM"}else{}
if (navigator.appName == "Netscape" &&
 parseInt(navigator.appVersion) >= 5){browsertype = "NN6xDOM"}else{}
//character tables
mycarii = new Array()
myaskii = new Array()
//small letters
mycarii[1] = "a"; myaskii[1] = "&#97;"
mycarii[2] = "b"; myaskii[2] = "&#98;"
mycarii[3] = "c"; myaskii[3] = "&#99;"
mycarii[4] = "d"; myaskii[4] = "&#100;"
mycarii[5] = "e"; myaskii[5] = "&#101;"
mycarii[6] = "f"; myaskii[6] = "&#102;"
mycarii[7] = "g"; myaskii[7] = "&#103;"
mycarii[8] = "h"; myaskii[8] = "&#104;"
mycarii[9] = "i"; myaskii[9] = "&#105;"
mycarii[10] = "j"; myaskii[10] = "&#106;"
mycarii[11] = "k"; myaskii[11] = "&#107;"
mycarii[12] = "l"; myaskii[12] = "&#108;"
mycarii[13] = "m"; myaskii[13] = "&#109;"
mycarii[14] = "n"; myaskii[14] = "&#110;"
mycarii[15] = "o"; myaskii[15] = "&#111;"
mycarii[16] = "p"; myaskii[16] = "&#112;"
mycarii[17] = "q"; myaskii[17] = "&#113;"
mycarii[18] = "r"; myaskii[18] = "&#114;"
mycarii[19] = "s"; myaskii[19] = "&#115;"
mycarii[20] = "t"; myaskii[20] = "&#116;"
mycarii[21] = "u"; myaskii[21] = "&#117;"
mycarii[22] = "v"; myaskii[22] = "&#118;"
mycarii[23] = "w"; myaskii[23] = "&#119;"
mycarii[24] = "x"; myaskii[24] = "&#120;"
mycarii[25] = "y"; myaskii[25] = "&#121;"
mycarii[26] = "z"; myaskii[26] = "&#122;"
//caps
mycarii[27] = "A"; myaskii[27] = "&#65;"
mycarii[28] = "B"; myaskii[28] = "&#66;"
mycarii[29] = "C"; myaskii[29] = "&#67;"
mycarii[30] = "D"; myaskii[30] = "&#68;"
mycarii[31] = "E"; myaskii[31] = "&#69;"
mycarii[32] = "F"; myaskii[32] = "&#70;"
mycarii[33] = "G"; myaskii[33] = "&#71;"
mycarii[34] = "H"; myaskii[34] = "&#72;"
mycarii[35] = "I"; myaskii[35] = "&#73;"
mycarii[36] = "J"; myaskii[36] = "&#74;"
mycarii[37] = "K"; myaskii[37] = "&#75;"
mycarii[38] = "L"; myaskii[38] = "&#76;"
mycarii[39] = "M"; myaskii[39] = "&#77;"
mycarii[40] = "N"; myaskii[40] = "&#78;"
mycarii[41] = "O"; myaskii[41] = "&#79;"
mycarii[42] = "P"; myaskii[42] = "&#80;"
mycarii[43] = "Q"; myaskii[43] = "&#81;"
mycarii[44] = "R"; myaskii[44] = "&#82;"
mycarii[45] = "S"; myaskii[45] = "&#83;"
mycarii[46] = "T"; myaskii[46] = "&#84;"
mycarii[47] = "U"; myaskii[47] = "&#85;"
mycarii[48] = "V"; myaskii[48] = "&#86;"
mycarii[49] = "W"; myaskii[49] = "&#87;"
mycarii[50] = "X"; myaskii[50] = "&#88;"
mycarii[51] = "Y"; myaskii[51] = "&#89;"
mycarii[52] = "Z"; myaskii[52] = "&#90;"
//numerals
mycarii[53] = "0"; myaskii[53] = "&#48;"
mycarii[54] = "1"; myaskii[54] = "&#49;"
mycarii[55] = "2"; myaskii[55] = "&#50;"
mycarii[56] = "3"; myaskii[56] = "&#51;"
mycarii[57] = "4"; myaskii[57] = "&#52;"
mycarii[58] = "5"; myaskii[58] = "&#53;"
mycarii[59] = "6"; myaskii[59] = "&#54;"
mycarii[60] = "7"; myaskii[60] = "&#55;"
mycarii[61] = "8"; myaskii[61] = "&#56;"
mycarii[62] = "9"; myaskii[62] = "&#57;"
//punctuation too
mycarii[63] = " "; myaskii[63] = "&#32;"
mycarii[64] = "\!"; myaskii[64] = "&#33;"
mycarii[65] = "\""; myaskii[65] = "&#34;"
mycarii[66] = "\#"; myaskii[66] = "&#35;"
mycarii[67] = "\$"; myaskii[67] = "&#36;"
mycarii[68] = "\%"; myaskii[68] = "&#37;"
mycarii[69] = "\&"; myaskii[69] = "&#38;"
mycarii[70] = "\'"; myaskii[70] = "&#39;"
mycarii[71] = "\("; myaskii[71] = "&#40;"
mycarii[72] = "\)"; myaskii[72] = "&#41;"
mycarii[73] = "\*"; myaskii[73] = "&#42;"
mycarii[74] = "\+"; myaskii[74] = "&#43;"
mycarii[75] = "\,"; myaskii[75] = "&#44;"
mycarii[76] = "\-"; myaskii[76] = "&#45;"
mycarii[77] = "\."; myaskii[77] = "&#46;"
mycarii[78] = "\/"; myaskii[78] = "&#47;"
//more punctuation
mycarii[79] = "\:"; myaskii[79] = "&#58;"
mycarii[80] = "\;"; myaskii[80] = "&#59;"
mycarii[81] = "\<"; myaskii[81] = "&#60"
mycarii[82] = "\="; myaskii[82] = "&#61;"
mycarii[83] = "\>"; myaskii[83] = "&#62"
mycarii[84] = "\?"; myaskii[84] = "&#63;"
mycarii[85] = "\@"; myaskii[85] = "&#64;"
mycarii[86] = "\["; myaskii[86] = "&#91;"
mycarii[87] = "\\"; myaskii[87] = "&#92;"
mycarii[88] = "\]"; myaskii[88] = "&#93;"
mycarii[89] = "\^"; myaskii[89] = "&#94;"
mycarii[90] = "\_"; myaskii[90] = "&#95;"
mycarii[91] = "\`"; myaskii[91] = "&#96;"
mycarii[92] = "\{"; myaskii[92] = "&#123;"
mycarii[93] = "\|"; myaskii[93] = "&#124;"
mycarii[94] = "\}"; myaskii[94] = "&#125;"
mycarii[95] = "\~"; myaskii[95] = "&#126;"
//Conversion function
function askMe(){
if (document.convertform.yourtext.value == ""){
 alert("Paste text in the top box first"); return;}else{};
var theirText = document.convertform.yourtext.value;
var theirConverted = "";
var inTag = false;
//convert characters into ascii equivalents
for(i=0; i<=theirText.length-1; i++){
 hari = "zzz";
 cari = theirText.charAt(i);
 if((cari == "\<") && (document.convertform.cb.checked)){inTag = true}else{}
 //searching for ascii value for each character
 for(j=1; j<=95; j++){
  if (cari == mycarii[j]){hari = myaskii[j];}else{}
 }
 //not found in my list, just put in the character
 if (hari == "zzz"){hari = cari}else{};
 //if in a tag
 if (inTag){
  hari = cari;
  if(cari == "\>"){inTag = false}else{}
  }else{}
 //add it on
 theirConverted += hari;
}
//output result
document.convertform.yourascii.value = theirConverted;
}
function exampleMe(){
xample = "Example with <bold>some tagged content</bold> in the middle.\n"
document.convertform.yourtext.value = xample;
askMe();
}
function clrMe(){
document.convertform.yourtext.value = "";
document.convertform.yourascii.value = "";
}
//popup
function popup(){
see=window.open('thecode/convascii_code.html','codewind','scrollbars,resizab
le,width=635,height=250')
see.focus()
}
//-->
</script>

  cari = theirText.charAt(i);
ma sostituire tutto il cut con:
    hari = theirText.charCodeAt(i)  ?
[altro cut]
--
a.cara

 ha scritto nel messaggio
news:c2nev9$1vl7or$1...@ID-163946.news.uni-berlin.de...
