12 Feb 2011 22:57
Re: My mp3 tagging code can't handle Unicode tags
Audio Ranger Development <developer <at> audioranger.com>
2011-02-12 21:57:47 GMT
2011-02-12 21:57:47 GMT
Peter, Louis,
when using a programming language that supports Unicode strings (like
Java or .NET), you can simply determine whether any given string can be
encoded with ISO-8859-1 or not as follows (pseudo code):
bool canBeISOEncoded(String s)
{
for (int i = 0; i < s.length(); i++)
{
if (s.charAt(i) > 0xFF)
return (false);
}
return (true);
}
The simple trick is to just check if the Unicode string contains any
characters with a value of > U+FF (decimal 255). If yes, you need to
encode the String as Unicode. If not, the chars fit into ISO-8859-1.
If you need to go for Unicode, common encodings are UTF-8, UTF-16 or
UTF-32. Each encoding has advantages and disadvantages. Regarding ID3
tags, you should use UTF-16 and ID3 version 2.3 tags in order to
maximize compatibility with other implementations.
Hope this helps.
Kind regards,
Mathias Kunter
Developer of Magic MP3 Tagger
(Continue reading)
RSS Feed