Denis Ross
Denis Ross

Reputation: 165

URLEncoder Cyrillic encode UTF-8 bad result

String text = URLEncoder.encode("кот", "UTF-8");
System.out.println("\nEncoding result : " + text);

Encoding result : %D0%A0%D1%94%D0%A0%D1%95%D0%A1%E2%80%9A

But I excpect: %D0%BA%D0%BE%D1%82 (looking here http://meyerweb.com/eric/tools/dencoder/)

What do I have to do to get %D0%BA%D0%BE%D1%82 as the result?

Upvotes: 0

Views: 205

Answers (1)

Klitos Kyriacou
Klitos Kyriacou

Reputation: 11664

Your IDE or editor is displaying your source file as UTF-8, but the javac compiler is probably using a default encoding according to your OS regional setting. Use the option javac -encoding utf-8 to override that.

Upvotes: 1

Related Questions