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?
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.