在处理json和响应时,您经常希望将字符串编码为java中的UTF-8.
String response = new String(response.data, UTF); // java code
For Kotlin, how is this done? I converted my Java class and the result was
String response = String(response.data, UTF) // kotlin code
But this results in an error, because I believe the Kotlin String() method is different than what I am doing in Java. Is it as simple as using the toString()?
String response = response.data.toString() // kotlin code
系统如何知道使用UTF-8,或者这只是默认值?这只是假设,但如果我想对String对象做些什么,并因此使用UTF-16呢?如何更改编码?