CTPP2Util.cpp | CTPP2Util.cpp | |||
---|---|---|---|---|
skipping to change at line 36 | skipping to change at line 36 | |||
* SUCH DAMAGE. | * SUCH DAMAGE. | |||
* | * | |||
* CTPP2Util.cpp | * CTPP2Util.cpp | |||
* | * | |||
* $CTPP$ | * $CTPP$ | |||
*/ | */ | |||
#include "CTPP2Util.hpp" | #include "CTPP2Util.hpp" | |||
#include "CDT.hpp" | #include "CDT.hpp" | |||
#include <stdio.h> | ||||
namespace CTPP // C++ Template Engine | namespace CTPP // C++ Template Engine | |||
{ | { | |||
static const UINT_32 aCRC32[] = | static const UINT_32 aCRC32[] = | |||
{ | { | |||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af4 8f, 0xe963a535, 0x9e6495a3, | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af4 8f, 0xe963a535, 0x9e6495a3, | |||
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17c bd, 0xe7b82d07, 0x90bf1d91, | 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17c bd, 0xe7b82d07, 0x90bf1d91, | |||
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4 eb, 0xf4d4b551, 0x83d385c7, | 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4 eb, 0xf4d4b551, 0x83d385c7, | |||
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066c d9, 0xfa0f3d63, 0x8d080df5, | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066c d9, 0xfa0f3d63, 0x8d080df5, | |||
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d4 47, 0xd20d85fd, 0xa50ab56b, | 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d4 47, 0xd20d85fd, 0xa50ab56b, | |||
skipping to change at line 450 | skipping to change at line 452 | |||
STLW::string sRetVal = ""; | STLW::string sRetVal = ""; | |||
UINT_32 iBufferPointer = 0; | UINT_32 iBufferPointer = 0; | |||
// Get string to escape | // Get string to escape | |||
STLW::string::const_iterator itsData = sData.begin(); | STLW::string::const_iterator itsData = sData.begin(); | |||
while (itsData != sData.end()) | while (itsData != sData.end()) | |||
{ | { | |||
UCHAR_8 chTMP = (UCHAR_8)(*itsData); | UCHAR_8 chTMP = (UCHAR_8)(*itsData); | |||
if (chTMP == '"') | if (chTMP < ' ') | |||
{ | ||||
if (iBufferPointer >= (CTPP_ESCAPE_BUFFER_LEN - 6)) | ||||
{ | ||||
sRetVal.append(sBuffer, iBufferPointer); | ||||
iBufferPointer = 0; | ||||
} | ||||
snprintf(sBuffer + iBufferPointer, 6, "\\u%04d", chT | ||||
MP); | ||||
} | ||||
else if (chTMP == '"') | ||||
{ | { | |||
if (iBufferPointer >= (CTPP_ESCAPE_BUFFER_LEN - 6)) | if (iBufferPointer >= (CTPP_ESCAPE_BUFFER_LEN - 6)) | |||
{ | { | |||
sRetVal.append(sBuffer, iBufferPointer); | sRetVal.append(sBuffer, iBufferPointer); | |||
iBufferPointer = 0; | iBufferPointer = 0; | |||
} | } | |||
sBuffer[iBufferPointer++] = '&'; | sBuffer[iBufferPointer++] = '&'; | |||
sBuffer[iBufferPointer++] = 'q'; | sBuffer[iBufferPointer++] = 'q'; | |||
sBuffer[iBufferPointer++] = 'u'; | sBuffer[iBufferPointer++] = 'u'; | |||
skipping to change at line 556 | skipping to change at line 567 | |||
return sRetVal; | return sRetVal; | |||
} | } | |||
// | // | |||
// Escape string, if need | // Escape string, if need | |||
// | // | |||
STLW::string EscapeJSONString(const STLW::string & sSource, const bool & bE CMAConventions, const bool & bHTMLSafe) | STLW::string EscapeJSONString(const STLW::string & sSource, const bool & bE CMAConventions, const bool & bHTMLSafe) | |||
{ | { | |||
STLW::string sResult; | STLW::string sResult; | |||
CHAR_8 szBuffer[128 + 1]; | ||||
const UINT_32 iSize = sSource.size(); | const UINT_32 iSize = sSource.size(); | |||
if (iSize == 0) { return sResult; } | if (iSize == 0) { return sResult; } | |||
UINT_32 iPos = 0; | UINT_32 iPos = 0; | |||
UINT_32 iPrevPos = 0; | UINT_32 iPrevPos = 0; | |||
for(;;) | for(;;) | |||
{ | { | |||
const UCHAR_8 uCH = sSource[iPos]; | const UCHAR_8 uCH = sSource[iPos]; | |||
if (uCH == '\r') | if (uCH == '\r') | |||
{ | { | |||
sResult.append(sSource, iPrevPos, iPos - iPrevPos); | sResult.append(sSource, iPrevPos, iPos - iPrevPos); | |||
iPrevPos = iPos + 1; | iPrevPos = iPos + 1; | |||
sResult.append("\\r", 2); | sResult.append("\\r", 2); | |||
} | } | |||
else if (uCH == '\n') | else if (uCH == '\n') | |||
{ | { | |||
sResult.append(sSource, iPrevPos, iPos - iPrevPos); | sResult.append(sSource, iPrevPos, iPos - iPrevPos); | |||
iPrevPos = iPos + 1; | iPrevPos = iPos + 1; | |||
skipping to change at line 606 | skipping to change at line 620 | |||
sResult.append(sSource, iPrevPos, iPos - iPrevPos); | sResult.append(sSource, iPrevPos, iPos - iPrevPos); | |||
iPrevPos = iPos + 1; | iPrevPos = iPos + 1; | |||
sResult.append("\\\\", 2); | sResult.append("\\\\", 2); | |||
} | } | |||
else if (uCH == '"') | else if (uCH == '"') | |||
{ | { | |||
sResult.append(sSource, iPrevPos, iPos - iPrevPos); | sResult.append(sSource, iPrevPos, iPos - iPrevPos); | |||
iPrevPos = iPos + 1; | iPrevPos = iPos + 1; | |||
sResult.append("\\\"", 2); | sResult.append("\\\"", 2); | |||
} | } | |||
else if (uCH < ' ' || (bECMAConventions && (uCH < ' ' && uCH | ||||
!= '\a' && uCH != '\v'))) | ||||
{ | ||||
sResult.append(sSource, iPrevPos, iPos - iPrevPos); | ||||
iPrevPos = iPos + 1; | ||||
snprintf(szBuffer, 7, "\\u%04d", uCH); | ||||
sResult.append(szBuffer, 6); | ||||
} | ||||
else if (bECMAConventions) | else if (bECMAConventions) | |||
{ | { | |||
if (uCH == '\'') | if (uCH == '\'') | |||
{ | { | |||
sResult.append(sSource, iPrevPos, iPos - iPr evPos); | sResult.append(sSource, iPrevPos, iPos - iPr evPos); | |||
iPrevPos = iPos + 1; | iPrevPos = iPos + 1; | |||
sResult.append("\\\'", 2); | sResult.append("\\\'", 2); | |||
} | } | |||
else if (uCH == '\a') | else if (uCH == '\a') | |||
{ | { | |||
End of changes. 5 change blocks. | ||||
1 lines changed or deleted | 24 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |