~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/utf8/unchecked.h

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

Show diffs side-by-side

added added

removed removed

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