Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69622 - in trunk: boost/property_tree/detail libs/property_tree/test
From: sebastian.redl_at_[hidden]
Date: 2011-03-07 04:46:01


Author: cornedbee
Date: 2011-03-07 04:45:58 EST (Mon, 07 Mar 2011)
New Revision: 69622
URL: http://svn.boost.org/trac/boost/changeset/69622

Log:
Better support for UTF-8. See bug 5203. Thanks to Qiaozhiqiang for tracking down the actual problem.
Text files modified:
   trunk/boost/property_tree/detail/rapidxml.hpp | 6 ++++--
   trunk/libs/property_tree/test/test_xml_parser_common.hpp | 10 +++++++++-
   trunk/libs/property_tree/test/xml_parser_test_data.hpp | 5 +++++
   3 files changed, 18 insertions(+), 3 deletions(-)

Modified: trunk/boost/property_tree/detail/rapidxml.hpp
==============================================================================
--- trunk/boost/property_tree/detail/rapidxml.hpp (original)
+++ trunk/boost/property_tree/detail/rapidxml.hpp 2011-03-07 04:45:58 EST (Mon, 07 Mar 2011)
@@ -313,8 +313,10 @@
         template<class Ch>
         inline size_t get_index(const Ch c)
         {
- // If not ASCII char, its sematic is same as plain 'z'
- if (c > 255)
+ // If not ASCII char, its semantic is same as plain 'z'.
+ // char could be signed, so first stretch and make unsigned.
+ unsigned n = c;
+ if (n > 127)
             {
                 return 'z';
             }

Modified: trunk/libs/property_tree/test/test_xml_parser_common.hpp
==============================================================================
--- trunk/libs/property_tree/test/test_xml_parser_common.hpp (original)
+++ trunk/libs/property_tree/test/test_xml_parser_common.hpp 2011-03-07 04:45:58 EST (Mon, 07 Mar 2011)
@@ -63,6 +63,7 @@
 {
 
     using namespace boost::property_tree;
+ typedef typename Ptree::data_type::value_type char_type;
 
     generic_parser_test_ok<Ptree, ReadFuncWS, WriteFuncWS>
     (
@@ -104,7 +105,7 @@
     (
         ReadFuncWS(), WriteFuncWS(), ok_data_5, NULL,
         "testok5.xml", NULL, "testok5out.xml",
- 3, umlautsize<typename Ptree::data_type::value_type>(), 12
+ 3, umlautsize<char_type>(), 12
     );
 
     generic_parser_test_error<Ptree, ReadFuncWS, WriteFuncWS, xml_parser_error>
@@ -131,6 +132,13 @@
         "testpr1678.xml", NULL, "testpr1678out.xml", 2, 0, 4
     );
 
+ generic_parser_test_ok<Ptree, ReadFuncWS, WriteFuncWS>
+ (
+ ReadFuncWS(), WriteFuncWS(), bug_data_pr5203, NULL,
+ "testpr5203.xml", NULL, "testpr5203out.xml",
+ 3, 4 * umlautsize<char_type>(), 13
+ );
+
 }
 
 #endif

Modified: trunk/libs/property_tree/test/xml_parser_test_data.hpp
==============================================================================
--- trunk/libs/property_tree/test/xml_parser_test_data.hpp (original)
+++ trunk/libs/property_tree/test/xml_parser_test_data.hpp 2011-03-07 04:45:58 EST (Mon, 07 Mar 2011)
@@ -768,4 +768,9 @@
 const char *bug_data_pr1678 =
     "\xEF\xBB\xBF<?xml version=\"1.0\" encoding=\"utf-8\"?><root/>";
 
+// russian
+const char *bug_data_pr5203 =
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+ "<name>\xD0\xAE\xD0\xBD\xD0\xB8\xD1\x82</name>";
+
 #endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk