I need convert String to UTF-8. Now in my code I have this:
sb.append(URLEncoder.encode(smsAnswerText, "UTF-8"))
but encode method throw exception UnsupportedEncodingException
I rewrite: sb.append(smsAnswerText)
becouse write this
and I have wrong tуxt -unreadable characters
Then I tried new String(smsAnswerText.getBytes(),StandardCharsets.UTF_8)
And this method throw exception too UnsupportedEncodingException
How can I convert Sting to String+UTF-8 without UnsupportedEncodingException
?
I need:
public static String generateBodyResponse(String smsAnswerText){
return// smsAnswerText in UTF-8
}
I have
public static String generateBodyResponse(String smsAnswerText) throws UnsupportedEncodingException{
return URLEncoder.encode(smsAnswerText, "UTF-8");
}