summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-12-20 11:32:10 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2019-12-20 11:32:13 +0000
commit91e22880bbf76c7607618e2139a6a88eb2ab6651 (patch)
tree35817cbd0553070cdb2d43542c1edc65aa7065f8
parentAdd a lexer rule for parsing text in bulk (diff)
downloadlibjsonpp-91e22880bbf76c7607618e2139a6a88eb2ab6651.tar.bz2
libjsonpp-91e22880bbf76c7607618e2139a6a88eb2ab6651.tar.xz
libjsonpp-91e22880bbf76c7607618e2139a6a88eb2ab6651.zip
Don't convert from UTF-8 to UTF-8 unnecessarily
-rw-r--r--libjsonpp/jsonFlexLexer.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/libjsonpp/jsonFlexLexer.cpp b/libjsonpp/jsonFlexLexer.cpp
index 54c3d21..802f9e0 100644
--- a/libjsonpp/jsonFlexLexer.cpp
+++ b/libjsonpp/jsonFlexLexer.cpp
@@ -2,9 +2,11 @@
#include <glibmm/convert.h>
namespace json {
+ const std::string UTF8 { "utf-8" };
+
jsonFlexLexer::jsonFlexLexer(std::istream & in, std::string enc, Value & v) :
yyFlexLexer(&in, nullptr),
- encoding(std::move(enc))
+ encoding(enc != UTF8 ? std::move(enc) : std::string())
{
yy_push_state(0);
acceptValues.push([&v](const auto & value) {
@@ -17,7 +19,7 @@ namespace json {
jsonFlexLexer::encodeBuf() const
{
if (!encoding.empty()) {
- return Glib::convert(buf, "utf-8", encoding);
+ return Glib::convert(buf, UTF8, encoding);
}
return buf;
}