Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60054 - in trunk/tools/quickbook: detail test
From: daniel_james_at_[hidden]
Date: 2010-03-01 14:40:31


Author: danieljames
Date: 2010-03-01 14:40:30 EST (Mon, 01 Mar 2010)
New Revision: 60054
URL: http://svn.boost.org/trac/boost/changeset/60054

Log:
Actually just pass through escaped unicoded characters as entities.
Text files modified:
   trunk/tools/quickbook/detail/actions.cpp | 21 +++++++++------
   trunk/tools/quickbook/test/unicode-escape.gold | 52 ++++++++++++++++++++--------------------
   2 files changed, 38 insertions(+), 35 deletions(-)

Modified: trunk/tools/quickbook/detail/actions.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.cpp (original)
+++ trunk/tools/quickbook/detail/actions.cpp 2010-03-01 14:40:30 EST (Mon, 01 Mar 2010)
@@ -14,7 +14,6 @@
 #include <boost/filesystem/convenience.hpp>
 #include <boost/filesystem/fstream.hpp>
 #include <boost/lexical_cast.hpp>
-#include <boost/regex/pending/unicode_iterator.hpp>
 #include "./quickbook.hpp"
 #include "./actions.hpp"
 #include "./utils.hpp"
@@ -418,16 +417,20 @@
 
     void escape_unicode_action::operator()(iterator first, iterator last) const
     {
- using namespace std;
- std::string value(first, last);
- boost::uint32_t unicode_value = strtol(value.c_str(), 0, 16);
- if(unicode_value < 128) {
- detail::print_char(unicode_value, phrase.get());
+ while(first != last && *first == '0') ++first;
+
+ // Just ignore \u0000
+ // Maybe I should issue a warning?
+ if(first == last) return;
+
+ std::string hex_digits(first, last);
+
+ if(hex_digits.size() == 2 && *first > '0' && *first <= '7') {
+ using namespace std;
+ detail::print_char(strtol(hex_digits.c_str(), 0, 16), phrase.get());
         }
         else {
- boost::utf8_output_iterator<ostream_iterator<char> > phrase_iter(
- ostream_iterator<char>(phrase.get()));
- *phrase_iter++ = unicode_value;
+ phrase << "&#x" << hex_digits << ";";
         }
     }
 

Modified: trunk/tools/quickbook/test/unicode-escape.gold
==============================================================================
--- trunk/tools/quickbook/test/unicode-escape.gold (original)
+++ trunk/tools/quickbook/test/unicode-escape.gold 2010-03-01 14:40:30 EST (Mon, 01 Mar 2010)
@@ -4,82 +4,82 @@
   <title>UTF-8 test</title>
   <articleinfo>
   </articleinfo>
- <anchor id="utf_8_test.i__t__rn__ti__n__liz__ti__n"/>
+ <anchor id="utf_8_test.i__xf1_t__xeb_rn__xe2_ti__xf4_n__xe0_liz__xe6_ti__xf8_n"/>
   <bridgehead renderas="sect2">
- <link linkend="utf_8_test.i__t__rn__ti__n__liz__ti__n">Iñtërnâtiônàlizætiøn</link>
+ <link linkend="utf_8_test.i__xf1_t__xeb_rn__xe2_ti__xf4_n__xe0_liz__xe6_ti__xf8_n">I&#xF1;t&#xEB;rn&#xE2;ti&#xF4;n&#xE0;liz&#xE6;ti&#xF8;n</link>
   </bridgehead>
   <itemizedlist>
     <listitem>
- Αα Alpha
+ &#x391;&#x3B1; Alpha
     </listitem>
     <listitem>
- Ββ Beta
+ &#x392;&#x3B2; Beta
     </listitem>
     <listitem>
- Γγ Gamma
+ &#x393;&#x3B3; Gamma
     </listitem>
     <listitem>
- Δδ Delta
+ &#x394;&#x3B4; Delta
     </listitem>
     <listitem>
- Εε Epsilon
+ &#x395;&#x3B5; Epsilon
     </listitem>
     <listitem>
- Ζζ Zeta
+ &#x396;&#x3B6; Zeta
     </listitem>
     <listitem>
- Ηη Eta
+ &#x397;&#x3B7; Eta
     </listitem>
     <listitem>
- Θθ Theta
+ &#x398;&#x3B8; Theta
     </listitem>
     <listitem>
- Ιι Iota
+ &#x399;&#x3B9; Iota
     </listitem>
     <listitem>
- Κκ Kappa
+ &#x39A;&#x3BA; Kappa
     </listitem>
     <listitem>
- Λλ Lambda
+ &#x39B;&#x3BB; Lambda
     </listitem>
     <listitem>
- Μμ Mu
+ &#x39C;&#x3BC; Mu
     </listitem>
     <listitem>
- Νν Nu
+ &#x39D;&#x3BD; Nu
     </listitem>
     <listitem>
- Ξξ Xi
+ &#x39E;&#x3BE; Xi
     </listitem>
     <listitem>
- Οο Omicron
+ &#x39F;&#x3BF; Omicron
     </listitem>
     <listitem>
- Ππ Pi
+ &#x3A0;&#x3C0; Pi
     </listitem>
     <listitem>
- Ρρ Rho
+ &#x3A1;&#x3C1; Rho
     </listitem>
     <listitem>
- Σσς Sigma
+ &#x3A3;&#x3C3;&#x3C2; Sigma
     </listitem>
     <listitem>
- Ττ Tau
+ &#x3A4;&#x3C4; Tau
     </listitem>
     <listitem>
- Υυ Upsilon
+ &#x3A5;&#x3C5; Upsilon
     </listitem>
     <listitem>
- Φφ Phi
+ &#x3A6;&#x3C6; Phi
     </listitem>
     <listitem>
- Χχ Chi
+ &#x3A7;&#x3C7; Chi
     </listitem>
     <listitem>
- Ψψ Psi
+ &#x3A8;&#x3C8; Psi
     </listitem>
     <listitem>
- Ωω Omega
+ &#x3A9;&#x3C9; Omega
     </listitem>
   </itemizedlist>
 </article>


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