0

I was playing around with Swing, and faced following problem with text encoding with JButton class

So would be grateful for explanation or some links explaining why this code display broken text - 'Р'РёР±СЂР°С, Рё':

JButton selectButton = new JButton("Вибрати");

but when I explicitly specify encoding everything works fine:

JButton selectButton = new JButton(new String("Вибрати".getBytes(), StandardCharsets.UTF_8));

File with code has UTF-8 encoding

12
  • File with code has UTF-8 encoding Are you sure - can you provide a link to it?
    – g00se
    Commented 19 hours ago
  • IntelliJ IDEA says UTF-8)) Here - github.com/momopoi443/sandbox
    – momopoi
    Commented 19 hours ago
  • Yes, it's UTF-8, but what does "doesn't work" mean?
    – g00se
    Commented 19 hours ago
  • 1
    javac -encoding UTF-8 Sanbox.java would probably make a difference
    – g00se
    Commented 19 hours ago
  • 1
    I see, use the -encoding option as commented by g00se (actually I would change the settings of windows to support UTF-8)
    – user85421
    Commented 18 hours ago

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.