Reputation: 446
I'm building an app that uses webservices that read from a MSSQL Server database. And as in MSSQL there is no UTF8 collation I'm using Modern_Spanish_CI_AS collation. I'm having troubles trying to get the information because chars with accents aren't read properly..
My webservices are built using Xojo framework and I think it's not a Xojo problem but I'm opened to any suggestion..
This is my Android code:
OutputStream os = conn.getOutputStream();
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(os, "UTF-8"));
if (postDataParams != null)
writer.write(getPostDataString(postDataParams));
writer.flush();
writer.close();
os.close();
int responseCode = conn.getResponseCode();
if (responseCode == HttpsURLConnection.HTTP_OK) {
String line;
BufferedReader br = new
BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
while ((line=br.readLine()) != null) {
response+=line;
}
br.close();
} else {
response = "";
}
conn.disconnect();
return response;
Do you know guys what can I do??
Thanks in advance!!
Upvotes: 1
Views: 102
Reputation: 12043
Your error seems to be that you're telling the input stream that it's reading UTF-8, whereas it actually is "Modern_Spanish_CI_AS". So you need to find the Xojo equivalent for that encoding and use that for the input. Then, the string's endcoding will match the text's data, and when you write it out, it'll be converted to UTF8 as you desire.
Upvotes: 1