When reading metadata using taglib - c++

I use taglib library for read mp3 file's metadata.
There is no problem when the metadata of any file is in English.
but when the metadata is composed in Korean, Korean does not print correctly.
How do I solve this problem? Could you give me some tips?
TagLib::FileRef f(path);
TagLib::AudioProperties *audioProperties = f.audioProperties();
if (!f.isNull() && f.tag()) {
TagLib::Tag* tag = f.tag();
strcpy_s(musicFile->album, sizeof(musicFile->album),
tag->album().toCString());
strcpy_s(musicFile->artist, sizeof(musicFile->artist),
tag->artist().toCString());
strcpy_s(musicFile->title, sizeof(musicFile->title),
tag->title().toCString());
strcpy_s(musicFile->genre, sizeof(musicFile->genre),
tag->genre().toCString());

Related

Why is libxml not storing html in my htmlDocPtr?

I am working on a piece of software that uses libxml to store xml on webpages in an xmlDocPtr. I need to expand this functionality to do the same for html.
The original code:
xmlDocPtr doc = xmlParseEntity(filename.c_str());
Where filename = 10.1.1.135/poll_data.xml and everything works just fine
Now, I have html filename = 10.1.1.165/index.htm and would like to store this as well. I have tried using htmlParseDoc with no success.
htmlDocPtr doc = htmlParseFile(filename.c_str(), "windows-1252");
The resulting doc object is not null but it does not contain the contents of the index.html
Netbeans spits out:
http://10.1.1.165/index.htm:1: HTML parser error : Document is empty
Any suggestions?

How to use contentURL in Research Kit to preform a online PDF file?

I've been looking into source code of Research Kit Example called ORKTest:
if (type.integerValue == ORKConsentSectionTypeDataGathering) {
/*
Tests PDF content instead of text, HTML for Learn More.
*/
NSString *path = [[NSBundle mainBundle] pathForResource:#"SAMPLE_PDF_TEST" ofType:#"pdf"];
consentSection.contentURL = [NSURL URLWithString:path];
}
It used a local PDF file path in .contentURL,and I'd like to replace it with a online PDF url such as http://examle.com/file/example.pdf
consentSection.contentURL = NSURL.fileURLWithPath("http://example.com/file/example.pdf")
or
consentSection.contentURL = NSURL.fileURLWithPath("example.com/file/example.pdf")
but only got an empty page(the url that I used worked fine on browser,just a pdf file).
Anyone got any ideas,please?
NSURL.fileURLWithPath only works with local files. You have to put it in app's sandbox, then ask consentSection to load it.

ActiveQt: Activate an already open word document

I am trying to write to an open word document using activeQt. I am trying to activate my word document, but i cant get it to work.
I can do this in VBA very easily:
Documents("my.doc").Activate
but not in Qt, this is what i have tried:
wordApplication = new QAxObject("Word.Application");
doc = wordApplication->querySubObject("Documents()","my.doc");
doc->dynamicCall("Activate()");
Documents() is supposed to contain all the open word documents, but for me it is empty for some reason.
I found the solution to my problem, by using the setControl function with the UUID for word I was able to access a word document that was already opened.
QAxObject* wordApplication;
QAxObject* doc;
wordApplication = new QAxObject(this);
wordApplication->setControl(("{000209FF-0000-0000-C000-000000000046}&"));
doc = wordApplication->querySubObject("Documents()","my.doc");

How to compile Qt library 4.7.1 with text codecs supported?

I've successfully built static Qt library and I could see plugins/codecs/libqcncodecs.a, but I still can not use GB18030 like this:
QTextCodec::codecForName("GB18030")
and all I still couldn't find Chinese related codecs by
foreach (int mib, QTextCodec::availableMibs()) {
QTextCodec *codec = QTextCodec::codecForMib(mib);
QString sortKey = codec->name().toUpper();
qDebug()<<sortKey;
}
That's the output of my app:
"SYSTEM"
"UTF-8"
"ISO-8859-1"
"ISO-8859-15"
"UTF-32LE"
"UTF-32BE"
"UTF-32"
"UTF-16LE"
"UTF-16BE"
"UTF-16"
"MULELAO-1"
"ROMAN8"
"TIS-620"
"WINSAMI2"
"APPLE ROMAN"
"WINDOWS-1258"
"WINDOWS-1257"
"WINDOWS-1256"
"WINDOWS-1255"
"WINDOWS-1254"
"WINDOWS-1253"
"WINDOWS-1252"
"WINDOWS-1251"
"WINDOWS-1250"
"IBM866"
"IBM874"
"IBM850"
"ISO-8859-16"
"ISO-8859-14"
"ISO-8859-13"
"ISO-8859-10"
"ISO-8859-9"
"ISO-8859-8"
"ISO-8859-7"
"ISO-8859-6"
"ISO-8859-5"
"ISO-8859-4"
"ISO-8859-3"
"ISO-8859-2"
"KOI8-U"
"KOI8-R"
"ISCII-MLM"
"ISCII-KND"
"ISCII-TLG"
"ISCII-TML"
"ISCII-ORI"
"ISCII-GJR"
"ISCII-PNJ"
"ISCII-BNG"
"ISCII-DEV"
"TSCII"
How to add Chinese textcodecs?
The documentation says: "To link statically against those plugins, you need to use the Q_IMPORT_PLUGIN() macro in your application and you need to add the required plugins to your build using QTPLUGIN."
I think you are missing a Q_IMPORT_PLUGIN(qcncodecs) in your application.

Does Qt Linguist offer the ability to add new entries to the editable .ts file?

I didn't find a way to do this - only to edit the translations to the existing fields.
If there is no way to achieve this - how should this be done (somehow automatically, because right now I was manually adding
<message>
<source>x</source>
<translation>xx</translation>
</message>
blocks to my .ts file and I assume that's not the correct way.
No, that's not the correct way :) Use tr() in the code to mark strings for translation.
For example
label->setText( tr("Error") );
The you run lupdate for your project to extract them to a .ts. See here for more details.
Or do you need to translate strings that are not in the source code?
I just wrote a python script to insert new entries
into the .ts file for a homegrown parser using ElementTree. It doesnt make the code pretty
when it adds it, but I believe it works just fine (so far):
from xml.etree import ElementTree as ET
tree = ET.parse(infile)
doc = tree.getroot()
for e in tree.getiterator()
if e.tag == "context":
for child in e.getchildren():
if child.tag == "name" and child.text == target:
elem = ET.SubElement(e, "message")
src = ET.SubElement(elem, "source")
src.text = newtext
trans = ET.SubElement(elem, "translation")
trans.text = "THE_TRANSLATION"
tree.write(outfile)
Where infile is the .ts file, outfile may be the same as infile or different.
target is the context you are looking for to add a new message into,
and newtext is of course the new source text.