I cannot set the encoding with ID3_Field::SetEncoding. The encoding remains unchanged even I have executed ID3_Tag::Update. I don't know whether this is a UTF-8-specific issue. Please read the following code.
// ...
ID3_Tag myTag;
myTag.Link(argv[1], ID3TT_ID3V2);
// ...
ID3_Frame* myFrame;
ID3_Field* myField;
ID3_TextEnc txtenc;
ID3_Tag::Iterator* iter = myTag.CreateIterator();
std::string tmptag;
cxxtools::IConverter ic("UTF-8", "BIG5-HKSCS:2001");
while (NULL != (myFrame = iter->GetNext()))
{
myField = myFrame->GetField(ID3FN_TEXT);
txtenc = myField->GetEncoding();
if(txtenc == ID3TE_ASCII)
{
tmptag = myField->GetRawText();
tmptag = ic.convert(tmptag);
if(!myField->SetEncoding(ID3TE_UTF8))
cerr << "Cannot change encoding." << endl;
myTag.Update();
myField->Set(tmptag.c_str());
myTag.Update();
if(myField->GetEncoding() == txtenc)
cerr << "Cannot change encoding." << endl;
}
}
myField = NULL;
delete iter;
// ...
The program reports "Cannot change encoding." with every tag.