public int getByteLength(String str) {


int strLength = 0;

char tempChar[] = new char[str.length()];


for (int i = 0; i < tempChar.length; i++) {

tempChar[i] = str.charAt(i);


if (tempChar[i] < 128) {

strLength++;

} else {

strLength += 2;

}

}


return strLength;

}

+ Recent posts