8 #ifndef BOOST_NOWIDE_CONVERT_H_INCLUDED     9 #define BOOST_NOWIDE_CONVERT_H_INCLUDED    12 #include <boost/locale/encoding_utf.hpp>    25     template<
typename CharOut,
typename CharIn>
    26     CharOut *
basic_convert(CharOut *buffer,
size_t buffer_size,CharIn 
const *source_begin,CharIn 
const *source_end)
    32         while(source_begin!=source_end) {
    33             using namespace boost::locale::utf;
    34             code_point c = utf_traits<CharIn>::template decode<CharIn const *>(source_begin,source_end);
    35             if(c==illegal || c==incomplete) {
    39             size_t width = utf_traits<CharOut>::width(c);
    40             if(buffer_size < width) {
    44             buffer = utf_traits<CharOut>::template encode<CharOut *>(c,buffer);
    56         template<
typename Char>
    57         Char 
const *basic_strend(Char 
const *s)
    73     inline char *
narrow(
char *output,
size_t output_size,
wchar_t const *source)
    75         return basic_convert(output,output_size,source,details::basic_strend(source));
    84     inline char *
narrow(
char *output,
size_t output_size,
wchar_t const *begin,
wchar_t const *end)
    95     inline wchar_t *
widen(
wchar_t *output,
size_t output_size,
char const *source)
    97         return basic_convert(output,output_size,source,details::basic_strend(source));
   106     inline wchar_t *
widen(
wchar_t *output,
size_t output_size,
char const *begin,
char const *end)
   117     inline std::string 
narrow(
wchar_t const *s)
   119         return boost::locale::conv::utf_to_utf<char>(s);
   126     inline std::wstring 
widen(
char const *s)
   128         return boost::locale::conv::utf_to_utf<wchar_t>(s);
   135     inline std::string 
narrow(std::wstring 
const &s) 
   137         return boost::locale::conv::utf_to_utf<char>(s);
   144     inline std::wstring 
widen(std::string 
const &s) 
   146         return boost::locale::conv::utf_to_utf<wchar_t>(s);
 char * narrow(char *output, size_t output_size, wchar_t const *source)
Definition: convert.hpp:73
 
wchar_t * widen(wchar_t *output, size_t output_size, char const *source)
Definition: convert.hpp:95
 
CharOut * basic_convert(CharOut *buffer, size_t buffer_size, CharIn const *source_begin, CharIn const *source_end)
Template function that converts a buffer of UTF sequences in range [source_begin,source_end) to the o...
Definition: convert.hpp:26