1

i want to build client/server application, the client is android (2.2) application, and the server is tomcat Java server ,IDE is Eclips

i want to send arabic data from server to client using servlet, i found this question here and it is very helpful ,but my problem is that when i used this:

info.setText(Farsi.Convert("وليم"));

it works good and print that arabic word, but when i print the arabic data comes from the server like this:

info.setText(Farsi.Convert(results[0]));

it prints strange english word so maybe the problem is on sending data from server to client, or in another place?

things may be helpful to know the problem

  1. i can print the arabic data on console on server and it works good
  2. the data is coming from mysql and the field is utf8_unicode_ci
  3. i send the data from server to client using servlet like this:response.setCharacterEncoding("UTF-8");response.setHeader("Info", word);

please any help!! ,because this application is my graduation project and i have to support arabic.

Thank You

Community
  • 1
  • 1
William Kinaan
  • 28,059
  • 20
  • 85
  • 118

1 Answers1

0

My point - you shouldn't use headers for arabic words, use response body instead.

The reason that is hidden here - by default java.lang.String constructors using default system encoding, and it could be NOT UTF-8 encoding. You should create string from byte arrays specifying UTF-8 encoding manually, but this is impossible when using headers, AFAIK.

HitOdessit
  • 7,198
  • 4
  • 36
  • 59