Result set is ascii code


#1

my code …

...............
String FEED_URL = "https://api.twitter.com/1.1/search/tweets.json?&q="+args[0];
....
HttpGet request = new HttpGet(FEED_URL);
.....
request.setHeader("Accept-Language","utf-8");
request.setHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
request.setHeader("Content-Type", "application/x-www-form-urlencoded");
.....
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(request);
InputStreamReader in = new InputStreamReader(response.getEntity().getContent(),"UTF-8");
BufferedReader reader = new BufferedReader(in);
String line = null;

        while ((line = reader.readLine()) != null) {
                System.out.println(line);
        }
        reader.close();

result…

{"statuses":[{"metadata":{"result_type":"recent","iso_language_code":"ko"},"created_at":"Mon Sep 29 10:39:30 +0000 2014","id":516537746299420672,"id_str":"516537746299420672","text":"\uc27d\uac8c \ud480\uc774\ud558\uba74 \ubc15\uadfc\ud61c\ub3c4 \uc2eb\uc740\ub370, \ubb38\uc7ac\uc778\ub3c4 \ud63c\uc790\ub9cc \uc9c4\uc601\ub17c\ub9ac\uc5d0 \uac07\ud600\uc788\ub294\uac83 \uac19\uc544 \ubcc4\ub85c\uc600\ub2e4\uace0.\u3161\u3161","source":"\u003ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":516536559261057024,"in_reply_to_status_id_str":"516536559261057024","in_reply_to_user_id":842765035,"in_reply_to_user_id_str":"842765035","in_reply_to_screen_name":"cholscc","user":{"id":842765035,"id_str":"842765035","name":"daily H.M","screen_name":"cholscc","location":"","description":"\uce5c\ub178\ubb38\ube60\ub294 \uc800\ucabd\uc73c\ub85c \ub098\uac00\uc2dc\uae38\ubc14\ub78d\ub2c8\ub2e4.",     .....

i don’t know …why result is ‘ascii’ code…


#2

It looks like that result is in Korean ("iso_language_code":"ko") so I expect the text content is in a DBCS format.


#3

Thanks…
but, i don’t know how can i convert the result to “UTF-8”…

Please…help me…


#4

There’s some information in our counting characters documentation about how this is handled by Twitter, but obviously how you choose to handle this will be specific to your language and app. Following the Byte Encodings and Strings tutorial for Java worked perfectly for me.


#5

Wow~~

Thank you~~ :smile: