Skip to content

Commit

Permalink
Fix output character type in writers
Browse files Browse the repository at this point in the history
  • Loading branch information
miloyip committed Jan 24, 2017
1 parent 942bb46 commit 3693e94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/rapidjson/prettywriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class PrettyWriter : public Writer<OutputStream, SourceEncoding, TargetEncoding,

void WriteIndent() {
size_t count = (Base::level_stack_.GetSize() / sizeof(typename Base::Level)) * indentCharCount_;
PutN(*Base::os_, static_cast<typename TargetEncoding::Ch>(indentChar_), count);
PutN(*Base::os_, static_cast<typename OutputStream::Ch>(indentChar_), count);
}

Ch indentChar_;
Expand Down
12 changes: 6 additions & 6 deletions include/rapidjson/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class Writer {
const char* end = internal::i32toa(i, buffer);
PutReserve(*os_, static_cast<size_t>(end - buffer));
for (const char* p = buffer; p != end; ++p)
PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(*p));
PutUnsafe(*os_, static_cast<typename OutputStream::Ch>(*p));
return true;
}

Expand All @@ -306,7 +306,7 @@ class Writer {
const char* end = internal::u32toa(u, buffer);
PutReserve(*os_, static_cast<size_t>(end - buffer));
for (const char* p = buffer; p != end; ++p)
PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(*p));
PutUnsafe(*os_, static_cast<typename OutputStream::Ch>(*p));
return true;
}

Expand All @@ -315,7 +315,7 @@ class Writer {
const char* end = internal::i64toa(i64, buffer);
PutReserve(*os_, static_cast<size_t>(end - buffer));
for (const char* p = buffer; p != end; ++p)
PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(*p));
PutUnsafe(*os_, static_cast<typename OutputStream::Ch>(*p));
return true;
}

Expand All @@ -324,7 +324,7 @@ class Writer {
char* end = internal::u64toa(u64, buffer);
PutReserve(*os_, static_cast<size_t>(end - buffer));
for (char* p = buffer; p != end; ++p)
PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(*p));
PutUnsafe(*os_, static_cast<typename OutputStream::Ch>(*p));
return true;
}

Expand Down Expand Up @@ -357,7 +357,7 @@ class Writer {
}

bool WriteString(const Ch* str, SizeType length) {
static const typename TargetEncoding::Ch hexDigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
static const typename OutputStream::Ch hexDigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
static const char escape[256] = {
#define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
//0 1 2 3 4 5 6 7 8 9 A B C D E F
Expand Down Expand Up @@ -413,7 +413,7 @@ class Writer {
else if ((sizeof(Ch) == 1 || static_cast<unsigned>(c) < 256) && RAPIDJSON_UNLIKELY(escape[static_cast<unsigned char>(c)])) {
is.Take();
PutUnsafe(*os_, '\\');
PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(escape[static_cast<unsigned char>(c)]));
PutUnsafe(*os_, static_cast<typename OutputStream::Ch>(escape[static_cast<unsigned char>(c)]));
if (escape[static_cast<unsigned char>(c)] == 'u') {
PutUnsafe(*os_, '0');
PutUnsafe(*os_, '0');
Expand Down

0 comments on commit 3693e94

Please sign in to comment.