<script>
document.write(substringB("我wo是shi一yi个ge好hao人ren",4,17)+"<br>");
document.write(substrB("我wo是shi一yi个ge好hao人ren",4,13));
function substringB(str,stat,end) {
var i,ch,s = "";
for(i=0;i<stat;i++) {
ch = str.charAt(i);
if(ch.charCodeAt() > 127 || ch.charCodeAt < 0)
stat--,end--;
}
for(;i<end;i++) {
ch = str.charAt(i);
if(ch.charCodeAt() > 127 || ch.charCodeAt < 0)
end--;
s += ch;
}
return s;
}
function substrB(str,stat,len) {
var i,ch,s = "";
for(i=0;i<stat;i++) {
ch = str.charAt(i);
if(ch.charCodeAt() > 127 || ch.charCodeAt < 0)
stat--,len--;
}
for(;i<len+stat+1;i++) {
ch = str.charAt(i);
if(ch.charCodeAt() > 127 || ch.charCodeAt < 0)
len--;
s += ch;
}
return s;
}
</script>
document.write(substringB("我wo是shi一yi个ge好hao人ren",4,17)+"<br>");
document.write(substrB("我wo是shi一yi个ge好hao人ren",4,13));
function substringB(str,stat,end) {
var i,ch,s = "";
for(i=0;i<stat;i++) {
ch = str.charAt(i);
if(ch.charCodeAt() > 127 || ch.charCodeAt < 0)
stat--,end--;
}
for(;i<end;i++) {
ch = str.charAt(i);
if(ch.charCodeAt() > 127 || ch.charCodeAt < 0)
end--;
s += ch;
}
return s;
}
function substrB(str,stat,len) {
var i,ch,s = "";
for(i=0;i<stat;i++) {
ch = str.charAt(i);
if(ch.charCodeAt() > 127 || ch.charCodeAt < 0)
stat--,len--;
}
for(;i<len+stat+1;i++) {
ch = str.charAt(i);
if(ch.charCodeAt() > 127 || ch.charCodeAt < 0)
len--;
s += ch;
}
return s;
}
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货