Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Include/json_cpp/details/json_parsing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
****/

#include <cctype>
#include <cstdlib>
#include <array>
#include <cwctype>
#include <type_traits>
#include "../json.h"

#if defined(_MSC_VER)
Expand Down Expand Up @@ -198,6 +201,17 @@ typename std::char_traits<CharType>::int_type eof()
return std::char_traits<CharType>::eof();
}

template <typename CharType>
bool is_whitespace_character(typename std::char_traits<CharType>::int_type ch)
{
if constexpr (std::is_same<CharType, wchar_t>::value)
{
return std::iswspace(static_cast<wint_t>(ch)) != 0;
}

return std::isspace(static_cast<unsigned char>(ch)) != 0;
}

template <typename CharType>
class JSON_StreamParser : public JSON_Parser<CharType>
{
Expand Down Expand Up @@ -305,7 +319,7 @@ typename JSON_Parser<CharType>::int_type JSON_Parser<CharType>::EatWhitespace()
{
auto ch = NextCharacter();

while ( ch != eof<CharType>() && iswspace(static_cast<wint_t>(ch)))
while ( ch != eof<CharType>() && is_whitespace_character<CharType>(ch))
{
ch = NextCharacter();
}
Expand Down
Loading