Frank
Frank

Reputation: 31096

Chinese character in URL with Java

I used the following line in Firefox's URL field :

http://www.baidu.com/s?wd=你

This line was generated by my Java program.

The last Chinese character in the URL field sometimes became: %C4%E3 [Correct]

Other times it became: %E4%BD%A0 [Incorrect]

I tried to use the URL with IE. It shows up still as , but the result page search field shows the character as . Could this be a UTF-8 or UTF-16 encoding problem? How do I get the correct code %C4%E3 from the char with my Java program?

Upvotes: 4

Views: 5437

Answers (1)

Bozho
Bozho

Reputation: 597114

URLEncoder.encode(string, encoding)

Upvotes: 1

Related Questions