I want to write something like this :
suspend fun String.decodeBase64(): String = withContext(Dispatchers.Default) {
BaseEncoding.base64().decode(this).toString(Charsets.UTF_8)
}
But I get an error on “this” because it references the CoroutineScope. Is there any syntax possibly with a qualified “this” that would make this error go away ?
My current workaround is very ugly :
suspend fun String.decodeBase64(): String
{
val thisString = this
return withContext(Dispatchers.Default) {
BaseEncoding.base64().decode(thisString).toString(Charsets.UTF_8)
}
}