~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/utf8/unchecked.h

  • Committer: Monty Taylor
  • Date: 2010-12-27 19:58:09 UTC
  • mto: This revision was merged to the branch mainline in revision 2038.
  • Revision ID: mordred@inaugust.com-20101227195809-1k7a4ge19l3u1o1h
Updated pandora-build files to version 0.171

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
#include "drizzled/utf8/core.h"
32
32
 
 
33
namespace drizzled
 
34
{
33
35
namespace utf8
34
36
{
35
37
    namespace unchecked 
45
47
            }
46
48
            else if (cp < 0x10000) {              // three octets
47
49
                *(result++) = static_cast<uint8_t>((cp >> 12)         | 0xe0);
48
 
                *(result++) = static_cast<uint8_t>((cp >> 6) & 0x3f   | 0x80);
 
50
                *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
49
51
                *(result++) = static_cast<uint8_t>((cp & 0x3f)        | 0x80);
50
52
            }
51
53
            else {                                // four octets
52
54
                *(result++) = static_cast<uint8_t>((cp >> 18)         | 0xf0);
53
 
                *(result++) = static_cast<uint8_t>((cp >> 12)& 0x3f   | 0x80);
54
 
                *(result++) = static_cast<uint8_t>((cp >> 6) & 0x3f   | 0x80);
 
55
                *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)| 0x80);
 
56
                *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
55
57
                *(result++) = static_cast<uint8_t>((cp & 0x3f)        | 0x80);
56
58
            }
57
59
            return result;
132
134
            while (start != end) {
133
135
                uint32_t cp = internal::mask16(*start++);
134
136
            // Take care of surrogate pairs first
135
 
                if (internal::is_surrogate(cp)) {
 
137
                if (internal::is_lead_surrogate(cp)) {
136
138
                    uint32_t trail_surrogate = internal::mask16(*start++);
137
139
                    cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
138
140
                }
144
146
        template <typename u16bit_iterator, typename octet_iterator>
145
147
        u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
146
148
        {
147
 
            while (start != end) {
 
149
            while (start < end) {
148
150
                uint32_t cp = next(start);
149
151
                if (cp > 0xffff) { //make a surrogate pair
150
152
                    *result++ = static_cast<uint16_t>((cp >> 10)   + internal::LEAD_OFFSET);
222
224
 
223
225
    } // namespace utf8::unchecked
224
226
} // namespace utf8 
 
227
} // namespace drizzled
225
228
 
226
229
 
227
230
#endif /* DRIZZLED_UTF8_UNCHECKED_H */