MCPcopy Create free account
hub / github.com/acl-dev/acl / test_unicode

Function test_unicode

lib_acl_cpp/samples/charset/main.cpp:234–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234static void test_unicode(void)
235{
236 acl::charset_conv conv;
237 acl::string in, out;
238 unsigned char i8;
239 unsigned short i16;
240 int i32, k = 0;
241 bool ret;
242
243 goto TAG;
244
245 i16 = 32;
246 in.copy((const void*) &i16, 2);
247 ret = conv.convert("UNICODE", "gb18030", in.c_str(), in.length(), &out);
248 if (ret == true)
249 {
250 if (out.length() == 1)
251 {
252 memcpy(&i8, out.c_str(), out.length());
253 k = i8;
254 }
255 else if (out.length() == 2)
256 {
257 memcpy(&i16, out.c_str(), out.length());
258 k = i16;
259 }
260 else if (out.length() > 2)
261 {
262 k = out.length() > sizeof(i32) ? sizeof(i32) : out.length();
263 memcpy(&i32, out.c_str(), k);
264 k = i32;
265 }
266
267 printf(">>result: %d, len: %d, %c%c\n", k, (int) out.length(), (int) k >> 8, k & 0xff);
268 }
269 else
270 printf("convert error\n");
271
272 printf("-------------------\n");
273
274TAG:
275
276 i16 = 0xc2f3;
277 i16 = 33296;
278#if 0
279 i16 = 17320;
280 i16 = 53558;
281 i16 = 43681;
282 ret = conv.convert("gb18030", "UCS-2", (char*) &i16, 2, &out);
283#else
284 i16 = 8211;
285 i16 = 8212;
286 i16 = 8801;
287 ret = conv.convert("UCS-2", "gb18030", (char*) &i16, 2, &out);
288#endif
289
290 printf(">>>>8801: %c\n", (unsigned char) 34);
291 if (ret == true)

Callers 1

mainFunction · 0.85

Calls 4

memcpyFunction · 0.85
convertMethod · 0.80
c_strMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…