From 8c60f99c721ae5b932d2ea13b68d7cdbe449fe9e Mon Sep 17 00:00:00 2001 From: Dave Gamble Date: Tue, 5 Feb 2013 17:38:48 +0000 Subject: [PATCH] fix handling of utf16 surrogate pairs! git-svn-id: http://svn.code.sf.net/p/cjson/code@46 e3330c51-1366-4df0-8b21-3ccf24e3d50e --- cJSON.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index 9262cb4..dc98985 100644 --- a/cJSON.c +++ b/cJSON.c @@ -174,7 +174,7 @@ static const char *parse_string(cJSON *item,const char *str) if (ptr[1]!='\\' || ptr[2]!='u') break; /* missing second-half of surrogate. */ sscanf(ptr+3,"%4x",&uc2);ptr+=6; if (uc2<0xDC00 || uc2>0xDFFF) break; /* invalid second-half of surrogate. */ - uc=0x10000 | ((uc&0x3FF)<<10) | (uc2&0x3FF); + uc=0x10000 + ((uc&0x3FF)<<10) | (uc2&0x3FF); } len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;