aboutsummaryrefslogtreecommitdiff
path: root/toys/example/test_utf8towc.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-10-31 15:51:02 -0500
committerRob Landley <rob@landley.net>2017-10-31 15:51:02 -0500
commite913247fec162437920266182834aedadcb03004 (patch)
tree8f61ef4d6dfdb0d256279d4e5e34347f498aa13b /toys/example/test_utf8towc.c
parentb2d8cf906502226904e149e20279a899ba22e035 (diff)
downloadtoybox-e913247fec162437920266182834aedadcb03004.tar.gz
Rename test_*.c to demo_*.c (because "make test_$CMD" means something already),
fluff out README, and add a comment to hostid explaining its deprecation.
Diffstat (limited to 'toys/example/test_utf8towc.c')
-rw-r--r--toys/example/test_utf8towc.c42
1 files changed, 0 insertions, 42 deletions
diff --git a/toys/example/test_utf8towc.c b/toys/example/test_utf8towc.c
deleted file mode 100644
index f939eaa7..00000000
--- a/toys/example/test_utf8towc.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* test_utf8towc() against libc mbrtowc()
- *
- * Copyright 2017 Rob Landley <rob@landley.net>
-
-USE_TEST_UTF8TOWC(NEWTOY(test_utf8towc, 0, TOYFLAG_USR|TOYFLAG_BIN))
-
-config TEST_UTF8TOWC
- bool "test_utf8towc"
- default n
- help
- usage: test_utf8towc
-
- Print differences between toybox's utf8 conversion routines vs libc du jour.
-*/
-
-#include "toys.h"
-
-void test_utf8towc_main(void)
-{
- mbstate_t mb;
- int len1, len2;
- unsigned u, h;
- wchar_t wc1, wc2;
-
- setlocale(LC_ALL, "en_US.UTF-8");
-
- memset(&mb, 0, sizeof(mb));
- for (u=1; u; u++) {
- char *str = (void *)&h;
-
- wc1 = wc2 = 0;
- len2 = 4;
- h = htonl(u);
- while (!*str) str++, len2--;
-
- len1 = mbrtowc(&wc1, str, len2, &mb);
- if (len1<0) memset(&mb, 0, sizeof(mb));
- len2 = utf8towc(&wc2, str, len2);
- if (len1 != len2 || wc1 != wc2)
- printf("%x %d %x %d %x\n", u, len1, wc1, len2, wc2);
- }
-}