2

我在 Android 活动中的 TextView 中遇到重音字符问题。渲染显示问号而不是字符“è”和“à”。流程是:从网络资源获取一个midi文件->提取歌词->将歌词放入TextView。我不明白编码或字符集是否有问题。我尝试使用“UTF-8”或“ISO ...”对文件进行编码,但每次尝试都失败了。你能帮助我吗?

提前致谢。

4

3 回答 3

2

在将歌词放入 textview 之前,您可以尝试这样的操作:

newLyrics = new String(oldString.getBytes("UTF-8"),"UTF-8");
于 2014-05-22T23:00:47.937 回答
0

检查一次:

https://www.csie.ntu.edu.tw/~r92092/ref/midi/

Midi 文件基本上由二进制格式 + ascii 值作为标头数据组成,因此如果您可以将其转换并表示为 -
如果您可以将该二进制格式编码为 base64,这会将任何数据转换为 ascii 安全文本

于 2016-09-16T11:34:16.213 回答
0

你可以试试下面的代码:

//String encode function
fun encodeEmoji(message: String): String {
    try {
        return URLEncoder.encode(
            message,
            "UTF-8"
        )
    } catch (e: UnsupportedEncodingException) {
        return message
    }

}


//String decode function
fun decodeEmoji(message: String): String {
    val myString: String? = null
    try {
        return URLDecoder.decode(
            message, "UTF-8"
        )
    } catch (e: UnsupportedEncodingException) {
            return message
    }

}

函数的使用

    var string:String=CommonMethod.encodeEmoji("your string")

    string=CommonMethod.decodeEmoji(string)
于 2018-12-28T11:43:56.560 回答