public static String handleText(String str, int maxLen) {
if (TextUtils.isEmpty(str)) {
return str;
}
int count = 0;
int endIndex=0;
for (int i = 0; i < str.length(); i++) {
char item = str.charAt(i);
if (item < 128) {
count = count + 1;
} else {
count = count + 2;
}
if(maxLen==count || (item>=128 && maxLen+1==count)){
endIndex=i;
}
}
if (count <= maxLen) {
return str;
} else {
return str.substring(0, endIndex) + "...";
}
}