mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-15 01:04:03 +00:00
f3d7c26de1
git-svn-id: svn+q:///qpdf/trunk@709 71b93d88-0707-0410-a8cf-f5a4172ac649
49 lines
769 B
C++
49 lines
769 B
C++
#include <qpdf/QPDF_Name.hh>
|
|
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
QPDF_Name::QPDF_Name(std::string const& name) :
|
|
name(name)
|
|
{
|
|
}
|
|
|
|
QPDF_Name::~QPDF_Name()
|
|
{
|
|
}
|
|
|
|
std::string
|
|
QPDF_Name::normalizeName(std::string const& name)
|
|
{
|
|
std::string result;
|
|
char num[4];
|
|
result += name[0];
|
|
for (unsigned int i = 1; i < name.length(); ++i)
|
|
{
|
|
char ch = name[i];
|
|
// Don't use locale/ctype here; follow PDF spec guidelines.
|
|
if (strchr("#()<>[]{}/%", ch) || (ch < 33) || (ch > 126))
|
|
{
|
|
sprintf(num, "#%02x", (unsigned char) ch);
|
|
result += num;
|
|
}
|
|
else
|
|
{
|
|
result += ch;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
std::string
|
|
QPDF_Name::unparse()
|
|
{
|
|
return normalizeName(this->name);
|
|
}
|
|
|
|
std::string
|
|
QPDF_Name::getName() const
|
|
{
|
|
return this->name;
|
|
}
|