So my program pass the validation, i actually complete the task but is printing in the .txt file some chinese characters instead of true or false
Someone do know why?
Im pretty sure its some bugs in the process of covert bytes to strings, but my solution its identical to the codegym solution...could the official solution wrong aswell?
Chinese characters
Under discussion
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
LennyMan
15 January 2021, 13:04
I am actually having some problem with these encoding.
For example here where i tried to get the messageDigest with this code:
I get as output :
nk���w�Ɏ�l{_
instead of a code with numbers and letters 0
Guadalupe Gagnon
15 January 2021, 15:17
That is because the encryption is in hexidecimal format while digest returns a byte array. You will need one more conversion. Try this:
0
Guadalupe Gagnon
14 January 2021, 20:15
Most likely this is a result of your files using a different char set. There are so many different char sets out there, and the general standard UTF-8 is only good for English speaking countries. When you are in a different country that uses a different char set, problems can occur.
Here is an article, from 2003, about charsets and how they can be a problem:
https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/
+2
LennyMan
15 January 2021, 12:33
Amazing answer, i've read the article its very interesting.
Back to the task, the problem should be here:
At the beginning i left the .getBytes() empty, than i tried with UTF_8 and aswell with other type that IntelliJ suggest me, but the problem its still the same.
I bought my computer in UK so should work with UTF_8, and i never had this problem with task about reading, writing files before this one. 0
LennyMan
15 January 2021, 13:14
I found the solution about this here:
So basically my .txt file for some reasons is encoded with UTF_16LE.
But still i have to figured out the problem above with the messageDigest example, where i am working with the console.. 0