function countCharacters(str,size){
var totalCount = 0;
var newStr = "";
for (var i=0; i<str.length; i++) {
var c = str.charCodeAt(i);
if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) {
totalCount++;
}else {
totalCount+=2;
}
if(totalCount<size){
newStr = str.substring(0,i+1);
}else{
return newStr+"...";
}
}
return newStr;
}