MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / operator()

Method operator()

LuaSTGPlus/UnicodeStringEncoding.cpp:152–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150 uint8_t m_cBuf[6];
151public:
152 bool operator() (char32_t input, uint8_t*& output, size_t& size)
153 {
154 int c;
155 uint32_t uinput = (uint32_t)input;
156
157 if (uinput < 0x80u)
158 c = 0;
159 else if (uinput < 0x800u)
160 c = 1;
161 else if (uinput < 0x10000u)
162 c = 2;
163 else if (uinput < 0x200000u)
164 c = 3;
165 else if (uinput < 0x4000000u)
166 c = 4;
167 else if (uinput < 0x80000000u)
168 c = 5;
169 else
170 {
171 m_cBuf[0] = (uint8_t)'?';
172 output = m_cBuf;
173 size = 1;
174 return true;
175 }
176
177 if (c == 0)
178 m_cBuf[0] = uinput;
179 else
180 {
181 // ����ֽ�
182 for (int i = c; i > 0; --i)
183 {
184 m_cBuf[i] = (uinput & 0x3Fu) | 0x80u;
185 uinput >>= 6;
186 }
187
188 // �������
189 m_cBuf[0] = (0xFEu << (6 - c)) | uinput;
190 }
191
192 // �
193 output = m_cBuf;
194 size = c + 1;
195 return true;
196 }
197};
198
199class Utf16Encoder

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected