~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/utf8/unchecked.h

  • Committer: Stewart Smith
  • Date: 2010-02-22 07:44:37 UTC
  • mfrom: (1283.17.4)
  • mto: (1283.19.1)
  • mto: This revision was merged to the branch mainline in revision 1449.
  • Revision ID: stewart@flamingspork.com-20100222074437-1a9x1n030tbtv1qv
Merged embeddded-innodb-store-table-proto into embedded-innodb-write-row.

Show diffs side-by-side

added added

removed removed

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