'Andrid charset issue with cyrilic and Base64.encode

I have a project with webView and text, whitch I take from server. This text is in web format (with HTML tags). And I try to set this text into webView using Base64.encode. The problem happend in API 22 - cyrilic symbols in text looks like wrong decoding.

val encodedHtml = fromBase64(text.toByteArray())
web_view.loadData(encodedHtml, "text/html", "base64")

fun fromBase64(str: ByteArray): String {
   return String(
       android.util.Base64.encode(str, android.util.Base64.DEFAULT),
         Charset.forName("ISO-8859-5")
      )
}

I tryed to use ""UTF-8" in Charset.forName() and other, but it still does not work. Numbers and latin symbols looks right, issue with just cyrilic symbols.

enter image description here

What should I use to fix it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source