我向gradle.properties编写了一些带有元音的文本,并在gradle.build中声明了resValue。在builds文件夹中的文件gradleResValues.xml中生成应用程序后,此变量包含不正确的符号。
我试着在gradle.build的compileOptions中设置编码,获取字符串(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发布于 2019-09-20 19:54:48
使用字符代码,如\u2321。
在您的案例中:
var appname = "Begr\u00fc\u00dfungstext"
fun main() {
println(appname) // output -> `Begrüßungstext`
}在gradle中,它的工作方式与在JVM上运行时相同。
发布于 2019-09-20 19:57:33
尝试使用Unicode对字符进行转义:
https://www.rapidtables.com/code/text/unicode-characters.html
ü -> \u00FC
ß -> \u00DF
Begrüßungstext -> Begr\u00FC\u00DFungstexthttps://stackoverflow.com/questions/58027692
复制相似问题