{
c1 = text.charAt(i);
c2 = text.charAt(i+1);
c3 = text.charAt(i+2);
if (c1 == '\n' && c2 == '\n' && c3 == '\n')
continue;
tmpstr += c1;
}
text = tmpstr;
oldlen = text.length;
//result = (addp) ? "" : " "; //用全角空格代替
result = (addp) ? "
" : " "; //用全角空格代替
count = 4;
oneretn = 0;
for(i=0; i{
c1 = text.charAt(i);
c2 = text.charAt(i+1);
c3 = text.charAt(i+2);
c4 = text.charAt(i+3);
c5 = text.charAt(i+4);
c6 = text.charAt(i+5);
c7 = text.charAt(i+6);
c8 = text.charAt(i+7);
if (c1 == '\n')
{
if (c2 == '\n')
{
if (oneretn == 1)
result += (addp) ? "
\n" : "\n";
else
result += (addp) ? "
\n\n" : "\n\n";
//result += " ";
result += " "; //用全角空格代替
count = 4;
i++;
oneretn = 0;
}
continue;
}
else
{
if (c1 == " " && count == 0)
{
continue;
}
else
{
if ((c1 == '\xa1' && c2 == '\xa1') && count == 0)
{
i++;
continue;
}
}
oneretn = 0;
if(c1 > '\xff')
{
result += c1;
count+=1;
if (c2 != '\n')
{
if (ishalfpun(c2))
{
result += c2;
count+=1;
i++;
}
else
{
if (c2 == '\x22' || c2== '\x27')
{
result += c2;
count+=1;
i++;
if (c3 != '\n')
{
if (ishalfpun(c3))
{
result += c3;
count+=1;
i++;
}
}
else
{
if (ishalfpun(c4))
{
result += c4;
count+=1;
i+=2;
}
}
}
}
}
else
{
if (ishalfpun(c3))
{
result += c3;
count+=1;
i+=2;
}
else
{
if (c3 == '\x22' || c3== '\x27')
{
result += c3;
count+=1;
i+=2;
if (c4 != '\n')
{
if (ishalfpun(c4))
{
result += c4;
count+=1;
i+=2;
}
}
else
{
if (ishalfpun(c5))
{
result += c5;
count+=1;
i+=3;
}
}
}
}
}
}
else if(c1 > '\x80')
{
if (c1 == '\xa1' && c2 == '\xa1')
{
i++;
continue;
}
result += c1;
result += c2;
count+=2;
i++;
if (c3 == '\n')
{
if (c4 == '\xa1' && c5 == '\xa3') //。
{
result += c4;
result += c5;
count+=2;
i+=3;
}
else
{
if (c4 == '\xa3' && c5 == '\xac') //,
{
result += c4;
result += c5;
count+=2;
i+=3;
}
else
{
if (c4 == '\xa3' && c5 == '\xbb') //;
{
result += c4;
result += c5;
count+=2;
i+=3;
}
else
{
if (c4 == '\xa3' && c5 == '\xba') //:
{
result += c4;
result += c5;
count+=2;
i+=3;
}
else
{
if (c4 == '\xa3' && c5 == '\xa1') //!
{
result += c4;
result += c5;
count+=2;
i+=3;
}
else
{
if ((c4 == '\xa1' && c5 == '\xb1') || (c4 == '\xa1' && c5 == '\xaf'))//”
{
result += c4;
result += c5;
count+=2;
i+=3;
if (c6 == '\n')
{
if (ispun(c7,c8) == 1)
{
result += c7;
result += c8;
count+=2;
i+=3;
}
}
else
{
if ((a =ispun(c6,c7)) == 1)
{
result += c6;
result += c7;
count+=2;
i+=2;
}
}
}
else
{
if (c3 == '\xa3' && c4 == '\xbf') //?
{
result += c3;
result += c4;
count+=2;
i+=3;
}
else
{
if (c3 == '\xa1' && c4 == '\xb7') //》
{
result += c3;
result += c4;
count+=2;
i+=3;
}
else
{
}
}
}
}
}
}
}
}
}
else
{
if (c3 == '\xa1' && c4 == '\xa3')
{
result += c3;
result += c4;
count+=2;
i+=2;
}
else
{
if (c3 == '\xa3' && c4 == '\xac')
{
result += c3;
result += c4;
count+=2;
i+=2;
}
else
{
if (c3 == '\xa3' && c4 == '\xbb')
{
result += c3;
result += c4;
count+=2;
i+=2;
}
else
{
if (c3 == '\xa3' && c4 == '\xba')
{
result += c3;
result += c4;
count+=2;
i+=2;
}
else
{
if (c3 == '\xa3' && c4 == '\xa1')
{
result += c3;
result += c4;
count+=2;
i+=2;
}
else
{
if ((c3 == '\xa1' && c4 == '\xb1') || (c3 == '\xa1' && c4 == '\xaf'))
{
result += c3;
result += c4;
count+=2;
i+=2;
if (c5 == '\n')
{
if (ispun(c6,c7) == 1)
{
result += c6;
result += c7;
count+=2;
i+=3;
}
}
else
{
if (ispun(c5,c6) == 1)
{
result += c5;
result += c6;
count+=2;
i+=2;
}
}
}
else
{
if (c3 == '\xa3' && c4 == '\xbf')
{
result += c3;
result += c4;
count+=2;
i+=2;
}
else
{
if (c3 == '\xa1' && c4 == '\xb7')
{
result += c3;
result += c4;
count+=2;
i+=2;
}
else
{
}
}
}
}
}
}
}
}
}
}
else
{
result += c1;
count++;
}
}
}
if(iresult += text.charAt(i);
if(addp)
result +="
\n";
//" "=>"
"
var naivete_array =result.split("
");
if (naivete_array.length >1)
{
result="";
for (loop=0; loop < naivete_array.length;loop++)
{
if(result != ""){ result = result +"
"+ naivete_array[loop];}
else{ result = naivete_array[loop];}
}
}
var naivete_array =result.split("
");
if (naivete_array.length >1)
{
result="";
for (loop=0; loop < naivete_array.length;loop++)
{
if(naivete_array[loop] !=""){
result = result +"
"+ naivete_array[loop];
}
}
}
//最后把结尾处的"
"滤掉
var naivete_array =result.split("
");
if (naivete_array.length >1)
{
result="";
for (loop=0; loop < naivete_array.length;loop++)
{
result = result + naivete_array[loop];
}
}
//最后把结尾处的"
"滤掉
var naivete_array =result.split("
");
if (naivete_array.length >1)
{
result="";
for (loop=0; loop < naivete_array.length;loop++)
{
result = result + naivete_array[loop];
}
}
//最后把结尾处的"
"滤掉
var naivete_array =result.split("
");
if (naivete_array.length >1)
{
result="";
for (loop=0; loop < naivete_array.length;loop++)
{
result = result + naivete_array[loop];
}
}
/*
//最后把"http://xxxx[ ]"替换为"http://xxx"滤掉????有点问题
var naivete_array =result.split("http:");
var mytag=0;
if (naivete_array.length >=0)
{
result="";
for (loop=0; loop < naivete_array.length;loop++)
{
mytag=naivete_array[loop].indexOf(' ');
if(mytag<0){
mytag=naivete_array[loop].indexOf(".html");
if(mytag>0){mytag+=5;}
}
if(mytag<0){
mytag=naivete_array[loop].indexOf(".shtml");
if(mytag>0){mytag+=6;}
}
if(naivete_array[loop].substring(0,2) =='//')
{
naivete_array[loop]='http:'+naivete_array[loop];
mytag=mytag+5;
}
if(naivete_array[loop].substring(0,7) =='http://' && mytag>5 && mytag<150)
{
myurl=naivete_array[loop].substring(0,mytag);
myurl_href=''+myurl+'';
if(loop>0){
if(naivete_array[loop-1].substring(naivete_array[loop-1].length-1,naivete_array[loop-1].length)=='>' || naivete_array[loop-1].substring(naivete_array[loop-1].length-5,naivete_array[loop-1].length)=='href=')
{
result = result + naivete_array[loop];
}
else
{
result = result + naivete_array[loop].replace(myurl,myurl_href);
}
}
}
else{result = result + naivete_array[loop];}
}
}
*/
naivete_array =result.split("");
if (naivete_array.length >=0)
{
result="";
for (loop=0; loop < naivete_array.length;loop++)
{
result = result + naivete_array[loop];
}
}
naivete_array =result.split("
");
if (naivete_array.length >=0)
{
result="";
for (loop=0; loop < naivete_array.length;loop++)
{
result = result + naivete_array[loop];
}
}
result="\n"+result
//result=result.replace(" ","");
//result=result.replace("," ");
//result=result.replace("
,"");
return result;
}