首页 新闻 会员 周边 捐助

Taglib Sharp库的乱码问题

0
悬赏园豆:20 [待解决问题] 浏览: 33次

想用Taglib写个小应用,但是用库读写的在文本框是正常的显示,但是在音乐文件的属性里却是乱码。问一下有没有其他园友用过这个库?

Demo:https://files.cnblogs.com/files/lzhdim/TagLib.rar

 

lzhdim的主页 lzhdim | 小虾三级 | 园豆:584
提问于:2025-03-04 23:47
< > 人人可用的开源BI工具
分享
所有回答(1)
0

你出问题出在Encoding.Default的使用上,你应该明确指明你的编码,而非默认。

Different computers can use different encodings as the default, and the default encoding can even change on a single computer. Therefore, data streamed from one computer to another or even retrieved at different times on the same computer might be translated incorrectly. In addition, the encoding returned by the Default property uses best-fit fallback to map unsupported characters to characters supported by the code page. For these two reasons, using the default encoding is generally not recommended. To ensure that encoded bytes are decoded properly, your application should use a Unicode encoding, such as UTF8Encoding or UnicodeEncoding, with a preamble. Another option is to use a higher-level protocol to ensure that the same format is used for encoding and decoding.

The C# string type is a sequence of 16-bit code units, typically interpreted as a UTF-16 string.

寂静的羽夏 | 园豆:2307 (老鸟四级) | 2025-03-05 09:43

那应该怎么修改呢???默认库里不需要那个编码的,但是也是乱码,所以想加个编码。。。

支持(0) 反对(0) lzhdim | 园豆:584 (小虾三级) | 2025-03-05 13:39

@lzhdim: 你把Encoding.Default不要用了,改成 UTF-16 枚举。

支持(0) 反对(0) 寂静的羽夏 | 园豆:2307 (老鸟四级) | 2025-03-05 13:47

@寂静的羽夏: 请给出具体的修改后的代码,谢谢。。。

支持(0) 反对(0) lzhdim | 园豆:584 (小虾三级) | 2025-03-05 13:50
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册
Top