pekingduck/metadsf

Issues with Chinese charaters

Opened this issue · 9 comments

I have problems with Chinese characters, e.g.

$ metadsf -t 20__夏日戀人.dsf
TALB=In Brasil (2016, SACD, �K�)
TRCK=1/11
TIT2=�K�
TDRC=1989
TPE1=�s�

The tags are properly displayed with other tools like foorbar2000.

When I remove and re-tag the DSF file with metadsf, it can be dispalyed with metadsf -t:

$ metadsf --remove-tags=TPE1,TIT2 20__夏日戀人.dsf
$ metadsf --set-tag=TPE1="梅艳芳" --set-tag=TIT2="夏日戀人" 20__夏日戀人.dsf
$ metadsf -t 20__夏日戀人.dsf
TALB=In Brasil (2016, SACD, �K�)
TRCK=1/11
TDRC=1989
TIT2=夏日戀人
TPE1=梅艳芳

However, the tags of the DSF are displayed in foobar2000 mis-encoded characters, see below:

grafik

My locale is set to de_UTF-8. I do not have any issues with Chinese characters using metaflac.

How do I fix this issue?

I fixed a similar issue by changing MetaDSF::printTags() as
std::cout << (*it)->frameID() << "=" << (*it)->toString().to8Bit(true) << std::endl;
You might give that a try.

Many thanks. I will give it a try.

I am not a coder. Please let me know where shall I apply the change, the following line in src/metadsf.cpp:

void MetaDSF::printTags(const char *prefix) const

If yes, in what? Replacing the line with the following seems not to be right:

std::cout << (*it)->frameID() << "=" << (*it)->toString().to8Bit(true) << std::endl;

Yes, that is the correct place. The to8Bit(true) tells it to convert the string to UTF-8. I'm not familiar enough with the specifics to know if that is the correct fix for you. UTF-8 should be able to handle any language. Without this change, I think it was outputting latin1 which cannot handle many languages. Would be nice if the author could take a look at this. Good luck.

Hi @dgheath .

Your recipe will only help to display the contents of the tag. But not for input. This is half the solution. And the other half is unknown to me.

Your recipe will only help to display the contents of the tag. But not for input. This is half the solution. And the other half is unknown to me.

@dgheath Yes, I can confirm. The display issue has been fixed with the change, i.e. metadsf -t works now. But the input issue using metadsf --set-tag still exists.

Hi all (@c856450 , @dgheath ).

$ ./metadsf -sTIT2=Тест test.dsf

simple view (not Ok)

$ ./metadsf -t test.dsf 
TALB=Depeche Mode
TCON=Other
TDRC=2006-05-02
TRCK=1
TIT2=ТеÑÑ

iconv convert (Ok)

$ ./metadsf -t test.dsf | iconv -t LATIN1
TALB=Depeche Mode
TCON=Other
TDRC=2006-05-02
TRCK=1
TIT2=Тест

Not work -e{LATIN1,UTF8,UTF16}!

Hi @c856450 .

For UTF8 small dirty patch.

metadsf/src/metadsf.cpp

Lines 156 to 163 in eb01fb5

int MetaDSF::setTag(const TagLib::String &key, const TagLib::String &val,
bool replace)
{
TagLib::StringList vals;
vals.append(val);
return setTag(key, vals, replace);
}

to

int MetaDSF::setTag(const TagLib::String &key, const TagLib::String &val, 
		    bool replace) 
{
  std::string valt = val.to8Bit(false);
  TagLib::String valu = TagLib::String(valt, _i->_encoding);
  TagLib::StringList vals;
  
  vals.append(valu);
  return setTag(key, vals, replace);
}

Result:

$ ./metadsf -sTIT2=Тест test.dsf
$ ./metadsf -t test.dsf 
TALB=Depeche Mode
TCON=Other
TDRC=2006-05-02
TRCK=1
TIT2=Тест

@zvezdochiot Wow! Wonderfull, this works now! Thank you so much, both!!!

The original metadsf.cpp seems to have considered the encoding. However, as pointed by @zvezdochiot -e{LATIN1,UTF8,UTF16} does not work.