Created
March 8, 2020 20:47
-
-
Save lebe-dev/31e31a3399c7885e298ed86810504676 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Create text file with windows-1251 (or any other non-utf8 encoding) - source.txt | |
// 2. Execute that code | |
val sourceContent = File("source.txt").readText(Charset.forName("windows-1251")) | |
File("utf8.txt").writeText(String(sourceContent.toByteArray())) | |
// 3. Check utf8.txt file and you'll see text file with utf-8 encoding | |
For example sample text in russian windows-1251: а вот и текст | |
Source file in hex (source.txt): | |
E0 20 E2 EE F2 20 E8 20 F2 E5 EA F1 F2 0A | |
After this code execution: | |
D0 B0 20 D0 B2 D0 BE D1 82 20 D0 B8 20 D1 82 D0 B5 D0 BA D1 81 D1 82 0A |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment