想用Taglib写个小应用,但是用库读写的在文本框是正常的显示,但是在音乐文件的属性里却是乱码。问一下有没有其他园友用过这个库?
Demo:https://files.cnblogs.com/files/lzhdim/TagLib.rar
你出问题出在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.
那应该怎么修改呢???默认库里不需要那个编码的,但是也是乱码,所以想加个编码。。。
@lzhdim: 你把Encoding.Default
不要用了,改成 UTF-16 枚举。
@寂静的羽夏: 请给出具体的修改后的代码,谢谢。。。