aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_Name.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2013-01-25 14:59:55 +0100
committerJay Berkenbilt <ejb@ql.org>2013-03-04 22:45:15 +0100
commit32b62035ce9d5d07f7396cc50a0c38215f19c906 (patch)
treec7ade8bcf294574d731dc2bc7cdf42524ee023d2 /libqpdf/QPDF_Name.cc
parent9f1594656cc4702b4b0e99a2787e18e4b00d54d3 (diff)
downloadqpdf-32b62035ce9d5d07f7396cc50a0c38215f19c906.tar.zst
Replace many calls to sprintf with QUtil::hex_encode
Add QUtil::hex_encode to encode binary data has a hexadecimal string, and use it in place of sprintf where possible.
Diffstat (limited to 'libqpdf/QPDF_Name.cc')
-rw-r--r--libqpdf/QPDF_Name.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/libqpdf/QPDF_Name.cc b/libqpdf/QPDF_Name.cc
index 19610bff..9adb25b5 100644
--- a/libqpdf/QPDF_Name.cc
+++ b/libqpdf/QPDF_Name.cc
@@ -2,6 +2,7 @@
#include <string.h>
#include <stdio.h>
+#include <qpdf/QUtil.hh>
QPDF_Name::QPDF_Name(std::string const& name) :
name(name)
@@ -16,7 +17,6 @@ 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)
{
@@ -24,8 +24,7 @@ QPDF_Name::normalizeName(std::string const& name)
// 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;
+ result += "#" + QUtil::hex_encode(std::string(&ch, 1));
}
else
{