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: а вот и текст |