I'm extracting text from a PDF using Poppler and used the following code to print the text:
for (std::vector<poppler::text_box>::iterator it = currpg.begin(); it != currpg.end(); ++it)
{
const char *txt = it->text().to_latin1().c_str();
printf("%s\n", txt);
}
It worked fine for all but one string: "Exemptions/Allowances:" which came out Ы`L/V.
I then tried the following code and the string printed properly:
for (std::vector<poppler::text_box>::iterator it = currpg.begin(); it != currpg.end(); ++it)
{
std::string txt = it->text().to_latin1();
printf("%s\n", txt.c_str());
}
For that one particular string, why does the conversion to c_str inside printf yield a different result than when conversion is done outside printf? I thought maybe the "/" was causing an issue but there were date strings that also had "/" and printed properly.