GH #176: Poco::JSON::Stringifier UTF encoding

This commit is contained in:
Alex Fabijanic
2014-05-27 22:23:10 -05:00
parent 1732938168
commit b2eb4fda59
6 changed files with 105 additions and 86 deletions

View File

@@ -221,7 +221,7 @@ private:
{
for(unsigned int i = 0; i < indent; i++) out << ' ';
out << '"' << getKey(it) << '"';
Stringifier::stringify(getKey(it), out);
out << ((indent > 0) ? " : " : ":");
Stringifier::stringify(getValue(it), out, indent + step, step);

View File

@@ -602,6 +602,10 @@ private:
static const int _stateTransitionTable[NR_STATES][NR_CLASSES];
static const int xx = -1;
bool isHighSurrogate(unsigned uc);
bool isLowSurrogate(unsigned uc);
unsigned decodeSurrogatePair(unsigned hi, unsigned lo);
Handler::Ptr _pHandler;
signed char _state;
signed char _beforeCommentState;
@@ -713,6 +717,24 @@ inline void Parser::growBuffer()
}
inline bool Parser::isHighSurrogate(unsigned uc)
{
return (uc & 0xFC00) == 0xD800;
}
inline bool Parser::isLowSurrogate(unsigned uc)
{
return (uc & 0xFC00) == 0xDC00;
}
inline unsigned Parser::decodeSurrogatePair(unsigned hi, unsigned lo)
{
return ((hi & 0x3FF) << 10) + (lo & 0x3FF) + 0x10000;
}
}} // namespace Poco::JSON