aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_Name.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2008-04-29 14:55:25 +0200
committerJay Berkenbilt <ejb@ql.org>2008-04-29 14:55:25 +0200
commit9a0b88bf7777c153dc46ace22db74ef24d51583a (patch)
treef567ac1cf2bf5071a611eb49323a935b6ac938ff /libqpdf/QPDF_Name.cc
downloadqpdf-9a0b88bf7777c153dc46ace22db74ef24d51583a.tar.zst
update release date to actual daterelease-qpdf-2.0
git-svn-id: svn+q:///qpdf/trunk@599 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libqpdf/QPDF_Name.cc')
-rw-r--r--libqpdf/QPDF_Name.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/libqpdf/QPDF_Name.cc b/libqpdf/QPDF_Name.cc
new file mode 100644
index 00000000..f57ced04
--- /dev/null
+++ b/libqpdf/QPDF_Name.cc
@@ -0,0 +1,46 @@
+
+#include <qpdf/QPDF_Name.hh>
+
+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 guidlines.
+ 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;
+}