Ticket #5716: spirit_wide_what.patch

File spirit_wide_what.patch, 1.2 KB (added by mlang@…, 11 years ago)

Proposed patch to use locale::conv::utf_to_utf to support streaming to ostream with char_type other then char.

  • boost/spirit/home/support/info.hpp

     
    1515#include <boost/variant/recursive_variant.hpp>
    1616#include <boost/variant/apply_visitor.hpp>
    1717#include <boost/foreach.hpp>
     18#include <boost/locale/encoding_utf.hpp>
    1819#include <boost/spirit/home/support/utf8.hpp>
    1920#include <list>
    2021#include <iterator>
     
    127128    struct simple_printer
    128129    {
    129130        typedef utf8_string string;
     131        typedef typename Out::char_type char_type;
    130132
    131133        simple_printer(Out& out)
    132134          : out(out) {}
     
    134136        void element(string const& tag, string const& value, int /*depth*/) const
    135137        {
    136138            if (value == "")
    137                 out << '<' << tag << '>';
     139                out << char_type('<')
     140                    << locale::conv::utf_to_utf<char_type>(tag)
     141                    << char_type('>');
    138142            else
    139                 out << '"' << value << '"';
     143                out << char_type('"')
     144                    << locale::conv::utf_to_utf<char_type>(value)
     145                    << char_type('"');
    140146        }
    141147
    142148        Out& out;