9 #ifndef BOOST_NOWIDE_UTF_HPP_INCLUDED    10 #define BOOST_NOWIDE_UTF_HPP_INCLUDED    47             if(0xD800 <= v && v <= 0xDFFF) 
    52 #ifdef BOOST_NOWIDE_DOXYGEN    53         template<
typename CharType, 
int size = sizeof(CharType)>
    77             template<
typename Iterator>
   121             template<
typename Iterator>
   128             template<
typename Iterator>
   134         template<
typename CharType, 
int size = sizeof(CharType)>
   137         template<
typename CharType>
   144                 unsigned char c = ci;
   147                 if(BOOST_UNLIKELY(c < 194))
   153                 if(BOOST_LIKELY(c <= 244))
   165                 } 
else if(value <= 0x7FF)
   168                 } 
else if(BOOST_LIKELY(value <= 0xFFFF))
   179                 unsigned char c = ci;
   180                 return (c & 0xC0) == 0x80;
   188             template<
typename Iterator>
   191                 if(BOOST_UNLIKELY(p == e))
   194                 unsigned char lead = *p++;
   199                 if(BOOST_UNLIKELY(trail_size < 0))
   207                 code_point c = lead & ((1 << (6 - trail_size)) - 1);
   214                     if(BOOST_UNLIKELY(p == e))
   219                     c = (c << 6) | (tmp & 0x3F);
   220                     BOOST_NOWIDE_FALLTHROUGH;
   222                     if(BOOST_UNLIKELY(p == e))
   227                     c = (c << 6) | (tmp & 0x3F);
   228                     BOOST_NOWIDE_FALLTHROUGH;
   230                     if(BOOST_UNLIKELY(p == e))
   235                     c = (c << 6) | (tmp & 0x3F);
   250             template<
typename Iterator>
   253                 unsigned char lead = *p++;
   261                 else if(BOOST_LIKELY(lead < 240)) 
   266                 code_point c = lead & ((1 << (6 - trail_size)) - 1);
   270                 case 3: c = (c << 6) | (static_cast<unsigned char>(*p++) & 0x3F); BOOST_NOWIDE_FALLTHROUGH;
   271                 case 2: c = (c << 6) | (static_cast<unsigned char>(*p++) & 0x3F); BOOST_NOWIDE_FALLTHROUGH;
   272                 case 1: c = (c << 6) | (static_cast<unsigned char>(*p++) & 0x3F);
   278             template<
typename Iterator>
   283                     *out++ = static_cast<char_type>(value);
   284                 } 
else if(value <= 0x7FF)
   286                     *out++ = static_cast<char_type>((value >> 6) | 0xC0);
   287                     *out++ = static_cast<char_type>((value & 0x3F) | 0x80);
   288                 } 
else if(BOOST_LIKELY(value <= 0xFFFF))
   290                     *out++ = static_cast<char_type>((value >> 12) | 0xE0);
   291                     *out++ = static_cast<char_type>(((value >> 6) & 0x3F) | 0x80);
   292                     *out++ = static_cast<char_type>((value & 0x3F) | 0x80);
   295                     *out++ = static_cast<char_type>((value >> 18) | 0xF0);
   296                     *out++ = static_cast<char_type>(((value >> 12) & 0x3F) | 0x80);
   297                     *out++ = static_cast<char_type>(((value >> 6) & 0x3F) | 0x80);
   298                     *out++ = static_cast<char_type>((value & 0x3F) | 0x80);
   304         template<
typename CharType>
   305         struct utf_traits<CharType, 2>
   310             static bool is_single_codepoint(uint16_t x)
   313                 return x <= 0xD7FF || x >= 0xE000;
   315             static bool is_first_surrogate(uint16_t x)
   318                 return 0xD800 <= x && x <= 0xDBFF;
   320             static bool is_second_surrogate(uint16_t x)
   323                 return 0xDC00 <= x && x <= 0xDFFF;
   325             static code_point combine_surrogate(uint16_t w1, uint16_t w2)
   327                 return ((
code_point(w1 & 0x3FF) << 10) | (w2 & 0x3FF)) + 0x10000;
   331                 if(is_first_surrogate(c))
   333                 if(is_second_surrogate(c))
   340                 return is_second_surrogate(c);
   345                 return !is_second_surrogate(c);
   348             template<
typename It>
   351                 if(BOOST_UNLIKELY(current == last))
   353                 uint16_t w1 = *current++;
   354                 if(BOOST_LIKELY(is_single_codepoint(w1)))
   363                 uint16_t w2 = *current++;
   364                 if(!is_second_surrogate(w2))
   366                 return combine_surrogate(w1, w2);
   368             template<
typename It>
   371                 uint16_t w1 = *current++;
   372                 if(BOOST_LIKELY(is_single_codepoint(w1)))
   376                 uint16_t w2 = *current++;
   377                 return combine_surrogate(w1, w2);
   383                 return u >= 0x10000 ? 2 : 1;
   385             template<
typename It>
   388                 if(BOOST_LIKELY(u <= 0xFFFF))
   390                     *out++ = static_cast<char_type>(u);
   394                     *out++ = static_cast<char_type>(0xD800 | (u >> 10));
   395                     *out++ = static_cast<char_type>(0xDC00 | (u & 0x3FF));
   401         template<
typename CharType>
   402         struct utf_traits<CharType, 4>
   420             template<
typename It>
   426             template<
typename It>
   429                 if(BOOST_UNLIKELY(current == last))
   441             template<
typename It>
   444                 *out++ = static_cast<char_type>(u);
 static const int max_width
Definition: utf.hpp:87
UTF Traits class - functions to convert UTF sequences to and from Unicode code points.
Definition: utf.hpp:57
static bool is_trail(char_type c)
Namespace that holds basic operations on UTF encoded sequences.
Definition: convert.hpp:20
static Iterator encode(code_point value, Iterator out)
static bool is_lead(char_type c)
static const code_point illegal
Special constant that defines illegal code point.
Definition: utf.hpp:33
uint32_t code_point
The integral type that can hold a Unicode code point.
Definition: utf.hpp:28
CharType char_type
Definition: utf.hpp:62
static code_point decode_valid(Iterator &p)
static int trail_length(char_type c)
static const code_point incomplete
Special constant that defines incomplete code point.
Definition: utf.hpp:38
static int width(code_point value)
bool is_valid_codepoint(code_point v)
the function checks if v is a valid code point
Definition: utf.hpp:43
static code_point decode(Iterator &p, Iterator e)