Minor Refactor

This commit is contained in:
tarsin committed 2023-01-03 12:29:39 +08:00
1 parent b36b8f3234
commit 327dd1c73f
3 files changed
+65 -149

No files matched your search

@@ -0,0 +1,18 @@
package com.hippo.util
import android.os.Build
import java.net.URLEncoder
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets
fun encode(s: String, charset: Charset): String {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
URLEncoder.encode(s, charset)
} else {
URLEncoder.encode(s, charset.name())
}
}
fun encodeUTF8(s: String): String {
return encode(s, StandardCharsets.UTF_8)
}