我正在尝试从Kannel发送阿拉伯短信(或法语短信),但客户端收到的结果并不完美(有时会出现阿拉伯文字“??????”)。
经过分析,我发现编码错误发生在我的bearbox和smsbox之间。我已经在发送短信的http请求中使用了“charset=utf-8&coding=2”,但是仍然存在同样的问题。
有人知道问题所在或者有更好的解决方案吗?
以下是我用于发送短信的代码:
感谢您。
经过分析,我发现编码错误发生在我的bearbox和smsbox之间。我已经在发送短信的http请求中使用了“charset=utf-8&coding=2”,但是仍然存在同样的问题。
有人知道问题所在或者有更好的解决方案吗?
以下是我用于发送短信的代码:
StringBuffer param = new StringBuffer()
param.append("http://localhost:1025/cgi-bin/sendsms?")
param.append(URLEncoder.encode("username","UTF-8")).append("=").append(URLEncoder.encode("xxx","UTF-8"))
param.append("&").append(URLEncoder.encode("password","UTF-8")).append("=").append(URLEncoder.encode("xxxx","UTF-8"))
param.append("&").append(URLEncoder.encode("to","UTF-8")).append("=").append(URLEncoder.encode(numTel,"UTF-8"));
param.append("&").append(URLEncoder.encode("charset","UTF-8")).append("=").append(URLEncoder.encode("utf-8","UTF-8"))
param.append("&").append(URLEncoder.encode("coding","UTF-8")).append("=").append(URLEncoder.encode("2","UTF-8"))
param.append("&").append(URLEncoder.encode("text","UTF-8")).append("=").append(URLEncoder.encode(text,"UTF-8"))
param.append("&").append(URLEncoder.encode("priority","UTF-8")).append("=").append(URLEncoder.encode(""+priority,"UTF-8"))
param.append("&").append(URLEncoder.encode("dlr-mask","UTF-8")).append("=").append(URLEncoder.encode("31","UTF-8"))
param.append("&").append(URLEncoder.encode("dlr-url","UTF-8")).append("=").append(URLEncoder.encode(urlString,"UTF-8"))
try{
URL url = new URL(param.toString())
System.out.println("INFO : Opening connection ")
HttpURLConnection urlconnection = (HttpURLConnection) url.openConnection()
System.out.println("INFO : Connection openned")
BufferedReader input = new BufferedReader( new InputStreamReader(urlconnection.getInputStream()))
String inputLine
while ((inputLine = input.readLine()) != null)
aResult.append(inputLine)
input.close()
}catch(Exception e){
e.printStackTrace()
return false
}
System.out.println("response : "+aResult.toString())
System.out.println("INFO : all sent disconnect.")
'
感谢您。