I have a problem on trimming whitespaces in Chinese characters. I tried to log the content and here is how it looks like:
When displaying it in textview, it does display Chinese characters but the problem is the whitespace before and after the string text. Can someone help me to encode/decode this? thanks in advance.
EDIT 1 : Added screenshot of result.
EDIT 2 : Added content charset in response.
HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
but I still get the square characters when logging and when displaying in XML layout, the square characters become whitespaces.
EDIT 3 : Added my working solution.
private String removeWhiteSpace(String oldString) {
String newString = null;
if (oldString.length() > 0) {
Character c = oldString.charAt(0);
boolean isWhiteSpace = Character.isWhitespace(c);
if (isWhiteSpace) {
newString = oldString.replace(c, ' ');
} else {
newString = oldString;
}
newString = newString.trim();
}
return newString;
}