views:

254

answers:

1

I cut and pasted the following line in to my Firefox url field :

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

This line was generated by my Java program.

The last Chinese char in the Firefox field sometimes became : %C4%E3 [ Correct ]

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

I tried to cut and paste the url into IE. In the url field it shows up still as "你", but the result page search field shows the char as "浣", could this be a unicode-8 or unicode-16 problem ? So I'm a bit confused. How do I get the correct code "%C4%E3" from the char "你" with my java program ?

A: 

URLEncoder.encode(string, encoding)

Bozho
The proper encoding is probably something like GB3212 or so. What the OP is seeing sometimes is UTF-8 (E4 BD A0).
Joey
looks like baidu is expecting GBK encoding.
irreputable
Yes, GBK is the right one, got it, thanks !
Frank