Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unicode problem

 
Fouad Fares
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm trying to send HTTP request to an sms provoder.
This request contains arabic text. The result of this arabic text is rubbish text.

Could you please advise me how can i set the unicode on my java request.
NB : I'm developping this program under Oracle Jdeveloper JDK 2 version 1.3

import java.sql.*;
import java.util.*;
import oracle.jdbc.driver.*;
import java.util.Vector;
import java.lang.String;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.*;
import java.io.*;
import java.net.URL;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.util.Properties;
import org.w3c.dom.*;
import java.lang.Integer;
import javax.swing.JOptionPane ;
import oracle.jdeveloper.html.*;
import javax.servlet.*;
import javax.servlet.http.*;
import oracle.jdbc.driver.*;
import oracle.xml.sql.query.OracleXMLQuery;
import java.lang.*;
import Jcls_Reuters_Divers.*;

...

URL csoftURL = new URL("http://...");
HttpURLConnection connection = (HttpURLConnection)csoftURL.openConnection();

String postBody = "Username=" + URLEncoder.encode(SMSID) + "&" +
"PIN=" + URLEncoder.encode(SMSPIN) + "&" +
"SendTo=" + URLEncoder.encode(s_mobile) + "&" +
"Message=" + URLEncoder.encode(s_return) + "&" +
"ReplyTo=" + URLEncoder.encode(SMSREPLYTO) + "&" +
"ResponseFormat=1";

connection.setRequestMethod("POST");
connection.setRequestProperty("content-type","utf-8");

// poster les param�tres
connection.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(connection.getOutputStream());
wr.write(postBody);
wr.flush();
wr.close();

// Avoir les r�sultats
connection.connect(); // throws IOException
int responseCode = connection.getResponseCode(); // 200, 404, etc
String responseMsg = connection.getResponseMessage(); // OK, Forbidden, etc

BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));

String oneline = "NULL";
div.WriteLog("debut SMS ");
while ( (oneline = br.readLine()) != null) {
WriteLog(oneline);
if (oneline.toUpperCase().indexOf("ACCEPTED") > 0)
{
InsertLog
}
}

Regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic