William Kinaan
William Kinaan

Reputation: 28799

eclipse server application doesn't support arabic chars

i am building a server application using eclipse , and the client is android application

when i used just Java application i can read arabic chars from mysql and can print it correctly to eclipse ,but on server application i can't , the results are question marks like this `?????`

i am trying to print the results on eclipse not on android

my connect to database is :

String unicode = "?useUnicode=yes&characterEncoding=UTF-8";
Class.forName("com.mysql.jdbc.Driver");
            con = (Connection) DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/ams-competation" + unicode,
                    username, password);

don't care about android , i am asking how to read and print arabic chars on eclipse server application

EDIT

seems like my problem is from the eclipse not from the connection because when i tried this System.out.println("روما"); , i got question marks and when i tried to check that question marks with this statements

if(q.getFirstChoice().equals("بيرلو"))
                System.out.println("dddd");

the results was dddd , so i can read it correctly from mysql , but my problem on printing the results

Upvotes: 0

Views: 434

Answers (1)

maaz
maaz

Reputation: 4493

The problem is system.out do not support UtF-8 characters so you should be using following code

PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
out.println(“some-utf8-string”);

you can also see the reference.

Edited:
Other workaround is

  • In the Run Configuration, Arguments tab, I added "-Dfile.encoding=UTF-8" to the VM arguments
  • In the Run configuration, Common tab, I set the Console Encoding to UTF-8

Upvotes: 1

Related Questions