From 91e22880bbf76c7607618e2139a6a88eb2ab6651 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 20 Dec 2019 11:32:10 +0000 Subject: Don't convert from UTF-8 to UTF-8 unnecessarily --- libjsonpp/jsonFlexLexer.cpp | 6 ++++-- 1 file 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 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; } -- cgit v1.2.3