我在 gradle.properties 中写入一些带有变音符号的文本,并在 gradle.build 中声明 resValue。在 builds 文件夹中的文件 gradleResValues.xml 中构建应用程序后,此变量包含不正确的符号。
我尝试在 gradle.build 中的compileOptions中设置编码,获取 String(variable.getBytes(), "UTF-8),但它不起作用。
APP_NAME = Begrüßungstext // in gradle.properties
resValue "string", "appName", APP_NAME //in gradle.build
<string name="appName" translatable="false">BegrüÃungstext</string> // in gradleResValues.xml
最佳答案
使用字符代码,例如\u2321
。
就您而言:
var appname = "Begr\u00fc\u00dfungstext"
fun main() {
println(appname) // output -> `Begrüßungstext`
}
在 gradle 中,它的工作方式相同,因为它在 JVM 上运行。
关于android - 带有元音变音字符的 Gradle.properties,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58027692/