0

I am currently working on a program that basically translates between English and Russian. However, when entering a Russian word, some of the characters are not encoded properly.

For example, 'привет', works fine but for 'яблоко', I get: '�?блоко' after encoding.

The code I have for the encoding is:

String s = new String(searchText.getBytes(), "UTF-8");
System.out.println(s);

Any help would be appreciated.

Thanks.

0

2 Answers 2

1

"UTF-8" is specifying that the String you are receiving is in UTF-8 format. Most likely it is in a different format.

If you use the correct encoding it should be fine.

Sign up to request clarification or add additional context in comments.

Comments

0

You need to make sure you have the necessary encoding setup on your console. If you are on windows command prompt, execute first-

chcp 65001 && start.bat

If you are using Eclipse, do-

Run Configuration -> Common-> Encoding -> Other -> UTF-8

Comments

Your Answer

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