+ for (i = 1; i < argc; i++) {
+ if (strncmp(argv[i], "U+", 2) == 0) {
+ /*
+ * We're making a big assumption here that
+ * wchar_t represents a Unicode codepoint.
+ * That technically isn't valid unless the
+ * C compiler defines __STDC_ISO_10646__, but
+ * we're going to assume now that it works.
+ */
+ errno = 0;
+ c = strtoul(argv[i] + 2, NULL, 16);
+ if (errno) {
+ fprintf(stderr, "Codepoint %s invalid\n",
+ argv[i]);
+ continue;
+ }
+ printf("%d\n", wcwidth(c));
+ } else {
+ getwidth(argv[i]);
+ }
+ }