From 43a2c5694ea58f92878710a17d680fe4d78b02a9 Mon Sep 17 00:00:00 2001 From: Sergey Kosarevsky Date: Mon, 29 Feb 2016 17:42:48 +0100 Subject: [PATCH] Play nice with different encodings --- include/rapidjson/reader.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index 352dbd8..a4cb0af 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -1298,8 +1298,14 @@ private: cont = handler.RawNumber(str, SizeType(length), false); } else { - const char* str = s.Pop(); - SizeType length = static_cast(s.Length()) - 1; + StackStream stackStream(stack_); + SizeType numCharsToCopy = s.Length(); + while (numCharsToCopy--) { + Transcoder::Transcode(is, stackStream); + } + stackStream.Put('\0'); + const typename TargetEncoding::Ch* str = stackStream.Pop(); + const SizeType length = static_cast(stackStream.Length()) - 1; cont = handler.RawNumber(str, SizeType(length), true); }