I receive data from a external Microsoft SQL 2008 database (I make queries with MyBatis). The data is encoded as "Windows-1252".
I have tried to re-encode to UTF-8:
String textoFormado = ...value from MyBatis... ;
String s = new String(textoFormado.getBytes("Windows-1252"), "UTF-8");
Almost the whole string is correctly decoded, but some letters with accents are not.
For example:
�vila
�?vila
Ávila
I solved it thanks to all.
I have the next project structure:
at first I had (MyBatis and Spring inject dependencies and params):
public class Pojo {
private String params;
public void setParams(String params) {
try {
this.params = params;
}
}
}
The solution:
public class Pojo {
private String params;
public void setParams(byte[] params) {
try {
this.params = new String(params, "UTF-8");
} catch (UnsupportedEncodingException e) {
this.params = null;
}
}
}