mirror of
				https://github.com/pocoproject/poco.git
				synced 2025-10-28 11:31:53 +01:00 
			
		
		
		
	Revert "Revert "Revert "Merge pull request #45 from RangelReale/jsonunicode"""
This reverts commit 86647bd8ba.
			
			
This commit is contained in:
		| @@ -38,7 +38,6 @@ | |||||||
| #include "Poco/JSON/JSONException.h" | #include "Poco/JSON/JSONException.h" | ||||||
| #include "Poco/Ascii.h" | #include "Poco/Ascii.h" | ||||||
| #include "Poco/Token.h" | #include "Poco/Token.h" | ||||||
| #include "Poco/UnicodeConverter.h" |  | ||||||
| #undef min | #undef min | ||||||
| #undef max | #undef max | ||||||
| #include <limits> | #include <limits> | ||||||
| @@ -141,28 +140,28 @@ public: | |||||||
| 				switch(c) | 				switch(c) | ||||||
| 				{ | 				{ | ||||||
| 				case '"' : | 				case '"' : | ||||||
| 					_value += '"'; | 					c = '"'; | ||||||
| 					break; | 					break; | ||||||
| 				case '\\' : | 				case '\\' : | ||||||
| 					_value += '\\'; | 					c = '\\'; | ||||||
| 					break; | 					break; | ||||||
| 				case '/' : | 				case '/' : | ||||||
| 					_value += '/'; | 					c = '/'; | ||||||
| 					break; | 					break; | ||||||
| 				case 'b' : | 				case 'b' : | ||||||
| 					_value += '\b'; | 					c = '\b'; | ||||||
| 					break; | 					break; | ||||||
| 				case 'f' : | 				case 'f' : | ||||||
| 					_value += '\f'; | 					c = '\f'; | ||||||
| 					break; | 					break; | ||||||
| 				case 'n' : | 				case 'n' : | ||||||
| 					_value += '\n'; | 					c = '\n'; | ||||||
| 					break; | 					break; | ||||||
| 				case 'r' : | 				case 'r' : | ||||||
| 					_value += '\r'; | 					c = '\r'; | ||||||
| 					break; | 					break; | ||||||
| 				case 't' : | 				case 't' : | ||||||
| 					_value += '\t'; | 					c = '\t'; | ||||||
| 					break; | 					break; | ||||||
| 				case 'u' : // Unicode | 				case 'u' : // Unicode | ||||||
| 				{ | 				{ | ||||||
| @@ -197,11 +196,7 @@ public: | |||||||
| 					{ | 					{ | ||||||
| 						throw JSONException("Invalid unicode"); | 						throw JSONException("Invalid unicode"); | ||||||
| 					} | 					} | ||||||
| 					//unicode to utf8 | 					c = unicode; | ||||||
| 					std::string utf8; |  | ||||||
| 					UnicodeConverter::toUTF8((const UTF32Char*)&unicode,1,utf8); |  | ||||||
| 					_value += utf8; |  | ||||||
|  |  | ||||||
| 					break; | 					break; | ||||||
| 				} | 				} | ||||||
| 				default: | 				default: | ||||||
| @@ -209,9 +204,8 @@ public: | |||||||
| 					throw JSONException(format("Invalid escape '%c' character used", (char) c)); | 					throw JSONException(format("Invalid escape '%c' character used", (char) c)); | ||||||
| 				} | 				} | ||||||
| 				} | 				} | ||||||
| 			}else{ |  | ||||||
| 				_value += c; |  | ||||||
| 			} | 			} | ||||||
|  | 			_value += c; | ||||||
| 			c = istr.get(); | 			c = istr.get(); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -859,35 +859,6 @@ void JSONTest::testTemplate() | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void JSONTest::testUnicode() |  | ||||||
| { |  | ||||||
| 	const unsigned char supp[] = {0x61, 0xE1, 0xE9, 0x78, 0xED, 0xF3, 0xFA, 0x0}; |  | ||||||
| 	std::string text((const char*) supp); |  | ||||||
|  |  | ||||||
| 	std::string json = "{ \"test\" : \"a\u00E1\u00E9x\u00ED\u00F3\u00FA\" }"; |  | ||||||
| 	Parser parser; |  | ||||||
|  |  | ||||||
| 	Var result; |  | ||||||
| 	try |  | ||||||
| 	{ |  | ||||||
| 		DefaultHandler handler; |  | ||||||
| 		parser.setHandler(&handler); |  | ||||||
| 		parser.parse(json); |  | ||||||
| 		result = handler.result(); |  | ||||||
| 	} |  | ||||||
| 	catch(JSONException& jsone) |  | ||||||
| 	{ |  | ||||||
| 		std::cout << jsone.message() << std::endl; |  | ||||||
| 		assert(false); |  | ||||||
| 	} |  | ||||||
| 	assert(result.type() == typeid(Object::Ptr)); |  | ||||||
|  |  | ||||||
| 	Object::Ptr object = result.extract<Object::Ptr>(); |  | ||||||
| 	Var test = object->get("test"); |  | ||||||
| 	assert(test.convert<std::string>() == text); |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  |  | ||||||
| std::string JSONTest::getTestFilesPath(const std::string& type) | std::string JSONTest::getTestFilesPath(const std::string& type) | ||||||
| { | { | ||||||
| 	std::ostringstream ostr; | 	std::ostringstream ostr; | ||||||
| @@ -947,7 +918,6 @@ CppUnit::Test* JSONTest::suite() | |||||||
| 	CppUnit_addTest(pSuite, JSONTest, testValidJanssonFiles); | 	CppUnit_addTest(pSuite, JSONTest, testValidJanssonFiles); | ||||||
| 	CppUnit_addTest(pSuite, JSONTest, testInvalidJanssonFiles); | 	CppUnit_addTest(pSuite, JSONTest, testInvalidJanssonFiles); | ||||||
| 	CppUnit_addTest(pSuite, JSONTest, testTemplate); | 	CppUnit_addTest(pSuite, JSONTest, testTemplate); | ||||||
| 	CppUnit_addTest(pSuite, JSONTest, testUnicode); |  | ||||||
|  |  | ||||||
| 	return pSuite; | 	return pSuite; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -76,7 +76,6 @@ public: | |||||||
| 	void testInvalidJanssonFiles(); | 	void testInvalidJanssonFiles(); | ||||||
| 	void testTemplate(); | 	void testTemplate(); | ||||||
| 	void testItunes(); | 	void testItunes(); | ||||||
| 	void testUnicode(); |  | ||||||
|  |  | ||||||
| 	void setUp(); | 	void setUp(); | ||||||
| 	void tearDown(); | 	void tearDown(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Alex
					Alex