| 38 | |
| 39 | template <typename T> |
| 40 | std::u32string local2wide(const T &local) |
| 41 | { |
| 42 | std::u32string wide; |
| 43 | uint32_t head = 0; |
| 44 | bool read_next = true; |
| 45 | for (auto it = local.begin(); it != local.end();) { |
| 46 | if (read_next) { |
| 47 | head = *(it++); |
| 48 | if (head & u8_blck_begin) |
| 49 | read_next = false; |
| 50 | else |
| 51 | wide.push_back(set_zero(head)); |
| 52 | } |
| 53 | else { |
| 54 | std::uint8_t tail = *(it++); |
| 55 | wide.push_back(set_zero(head << 8 | tail)); |
| 56 | read_next = true; |
| 57 | } |
| 58 | } |
| 59 | if (!read_next) |
| 60 | throw cs::runtime_error("Codecvt: Bad encoding."); |
| 61 | return std::move(wide); |
| 62 | } |
| 63 | } // namespace codecvt_gbk |
| 64 | |
| 65 | namespace cs { |
no test coverage detected