@@ -56,23 +56,22 @@ static uint32_t unicode_cpt_from_utf8(const std::string & utf8, size_t & offset)
56
56
offset += 4 ;
57
57
return result;
58
58
}
59
- throw std::invalid_argument (" invalid string " );
59
+ throw std::invalid_argument (" failed to convert utf8 to codepoint " );
60
60
}
61
61
62
- static std::vector<uint16_t > unicode_cpt_to_utf16 (uint32_t cp) {
63
- std::vector<uint16_t > result;
64
- if (/* 0x0000 <= cp && */ cp <= 0xffff ) {
65
- result.emplace_back (cp);
66
- }
67
- else if (0x10000 <= cp && cp <= 0x10ffff ) {
68
- result.emplace_back (0xd800 | ((cp - 0x10000 ) >> 10 ));
69
- result.emplace_back (0xdc00 | ((cp - 0x10000 ) & 0x03ff ));
70
- }
71
- else {
72
- throw std::invalid_argument (" invalid cpt" );
73
- }
74
- return result;
75
- }
62
+ // static std::vector<uint16_t> unicode_cpt_to_utf16(uint32_t cp) {
63
+ // std::vector<uint16_t> result;
64
+ // if (/* 0x0000 <= cp && */ cp <= 0xffff) {
65
+ // result.emplace_back(cp);
66
+ // return result;
67
+ // }
68
+ // if (0x10000 <= cp && cp <= 0x10ffff) {
69
+ // result.emplace_back(0xd800 | ((cp - 0x10000) >> 10));
70
+ // result.emplace_back(0xdc00 | ((cp - 0x10000) & 0x03ff));
71
+ // return result;
72
+ // }
73
+ // throw std::invalid_argument("failed to convert codepoint to utf16");
74
+ // }
76
75
77
76
// static std::vector<uint16_t> unicode_cpts_to_utf16(const std::vector<uint32_t> & cps) {
78
77
// std::vector<uint16_t> result;
@@ -83,28 +82,28 @@ static std::vector<uint16_t> unicode_cpt_to_utf16(uint32_t cp) {
83
82
// return result;
84
83
// }
85
84
86
- static uint32_t cpt_from_utf16 (const std::vector<uint16_t > & utf16, size_t & offset) {
87
- assert (offset < utf16.size ());
88
- if (((utf16[0 ] >> 10 ) << 10 ) != 0xd800 ) {
89
- auto result = utf16[offset + 0 ];
90
- offset += 1 ;
91
- return result;
92
- }
93
-
94
- if (offset + 1 >= utf16.size () || !((utf16[1 ] & 0xdc00 ) == 0xdc00 )) {
95
- throw std::invalid_argument (" invalid character" );
96
- }
97
-
98
- auto result = 0x10000 + (((utf16[0 ] & 0x03ff ) << 10 ) | (utf16[1 ] & 0x03ff ));
99
- offset += 2 ;
100
- return result;
101
- }
85
+ // static uint32_t unicode_cpt_from_utf16 (const std::vector<uint16_t> & utf16, size_t & offset) {
86
+ // assert(offset < utf16.size());
87
+ // if (((utf16[0] >> 10) << 10) != 0xd800) {
88
+ // auto result = utf16[offset + 0];
89
+ // offset += 1;
90
+ // return result;
91
+ // }
92
+ //
93
+ // if (offset + 1 >= utf16.size() || !((utf16[1] & 0xdc00) == 0xdc00)) {
94
+ // throw std::invalid_argument("invalid character");
95
+ // }
96
+ //
97
+ // auto result = 0x10000 + (((utf16[0] & 0x03ff) << 10) | (utf16[1] & 0x03ff));
98
+ // offset += 2;
99
+ // return result;
100
+ // }
102
101
103
102
// static std::vector<uint32_t> unicode_cpts_from_utf16(const std::vector<uint16_t> & utf16) {
104
103
// std::vector<uint32_t> result;
105
104
// size_t offset = 0;
106
105
// while (offset < utf16.size()) {
107
- // result.push_back(cpt_from_utf16 (utf16, offset));
106
+ // result.push_back(unicode_cpt_from_utf16 (utf16, offset));
108
107
// }
109
108
// return result;
110
109
// }
0 commit comments