aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-01-25 23:08:40 +0100
committerMattias Andrée <m@maandree.se>2026-01-25 23:08:40 +0100
commitd0caefee7e2a45aebf14a6911021c7af9aed2a9f (patch)
tree72c074eebb678316d6e636767ab29494ef102b30
parentAdd control character representations (diff)
downloadcharconv-d0caefee7e2a45aebf14a6911021c7af9aed2a9f.tar.gz
charconv-d0caefee7e2a45aebf14a6911021c7af9aed2a9f.tar.bz2
charconv-d0caefee7e2a45aebf14a6911021c7af9aed2a9f.tar.xz
Add chess
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r--Makefile16
-rw-r--r--convert-to-chess.c25
-rw-r--r--convert-to-rotated-45deg-ccw.c4
-rw-r--r--convert-to-rotated-45deg-cw.c4
-rw-r--r--convert-to-rotated-90deg-ccw.c4
-rw-r--r--convert-to-rotated-90deg-cw.c4
-rw-r--r--libcharconv.h45
-rw-r--r--libcharconv_chess_black.c42
-rw-r--r--libcharconv_chess_neutral.c35
-rw-r--r--libcharconv_chess_white.c42
-rw-r--r--libcharconv_flipped.c2
-rw-r--r--libcharconv_latin.c19
-rw-r--r--libcharconv_mirrored.c12
-rw-r--r--libcharconv_negative.c40
-rw-r--r--libcharconv_overlaid.c40
-rw-r--r--libcharconv_rotated_45deg_ccw.c78
-rw-r--r--libcharconv_rotated_45deg_cw.c78
-rw-r--r--libcharconv_rotated_90deg_ccw.c144
-rw-r--r--libcharconv_rotated_90deg_cw.c144
-rw-r--r--libcharconv_turned.c30
20 files changed, 784 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index 2777447..293dc8b 100644
--- a/Makefile
+++ b/Makefile
@@ -74,7 +74,12 @@ BIN =\
convert-to-symbols\
convert-to-control-characters\
convert-to-xiangqi\
- convert-to-control-character-representations
+ convert-to-control-character-representations\
+ convert-to-chess\
+ convert-to-rotated-45deg-cw\
+ convert-to-rotated-90deg-cw\
+ convert-to-rotated-45deg-ccw\
+ convert-to-rotated-90deg-ccw
LIBOBJ =\
libcharconv_decode_utf8_.o\
@@ -138,7 +143,14 @@ LIBOBJ =\
libcharconv_control_characters.o\
libcharconv_xiangqi_red.o\
libcharconv_xiangqi_black.o\
- libcharconv_control_character_representations.o
+ libcharconv_control_character_representations.o\
+ libcharconv_chess_white.o\
+ libcharconv_chess_black.o\
+ libcharconv_chess_neutral.o\
+ libcharconv_rotated_45deg_cw.o\
+ libcharconv_rotated_90deg_cw.o\
+ libcharconv_rotated_45deg_ccw.o\
+ libcharconv_rotated_90deg_ccw.o
LOBJ = $(LIBOBJ:.o=.lo)
diff --git a/convert-to-chess.c b/convert-to-chess.c
new file mode 100644
index 0000000..b08c90c
--- /dev/null
+++ b/convert-to-chess.c
@@ -0,0 +1,25 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+USAGE("[-w | -b | -n]");
+
+
+int
+main(int argc, char *argv[])
+{
+ int black = 0;
+
+ ARGBEGIN {
+ case 'b': black = 1; break;
+ case 'w': black = 0; break;
+ case 'n': black = -1; break;
+ default:
+ usage();
+ } ARGEND;
+ if (argc)
+ usage();
+
+ return convert(black < 0 ? &libcharconv_chess_neutral :
+ black > 0 ? &libcharconv_chess_black :
+ &libcharconv_chess_white);
+}
diff --git a/convert-to-rotated-45deg-ccw.c b/convert-to-rotated-45deg-ccw.c
new file mode 100644
index 0000000..651a474
--- /dev/null
+++ b/convert-to-rotated-45deg-ccw.c
@@ -0,0 +1,4 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+SIMPLE(libcharconv_rotated_45deg_ccw)
diff --git a/convert-to-rotated-45deg-cw.c b/convert-to-rotated-45deg-cw.c
new file mode 100644
index 0000000..5abad1b
--- /dev/null
+++ b/convert-to-rotated-45deg-cw.c
@@ -0,0 +1,4 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+SIMPLE(libcharconv_rotated_45deg_cw)
diff --git a/convert-to-rotated-90deg-ccw.c b/convert-to-rotated-90deg-ccw.c
new file mode 100644
index 0000000..fa5c657
--- /dev/null
+++ b/convert-to-rotated-90deg-ccw.c
@@ -0,0 +1,4 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+SIMPLE(libcharconv_rotated_90deg_ccw)
diff --git a/convert-to-rotated-90deg-cw.c b/convert-to-rotated-90deg-cw.c
new file mode 100644
index 0000000..341012c
--- /dev/null
+++ b/convert-to-rotated-90deg-cw.c
@@ -0,0 +1,4 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+SIMPLE(libcharconv_rotated_90deg_cw)
diff --git a/libcharconv.h b/libcharconv.h
index 14627c6..fb8fa60 100644
--- a/libcharconv.h
+++ b/libcharconv.h
@@ -335,6 +335,9 @@ LIBCHARCONV_FUNC_(libcharconv_flipped);
/**
* Overlay characters
+ *
+ * Filled and outlined characters can be combined
+ * to create a mixed, when there is a mixed version
*/
LIBCHARCONV_FUNC_(libcharconv_overlaid);
@@ -391,13 +394,13 @@ LIBCHARCONV_FUNC_(libcharconv_symbols);
LIBCHARCONV_FUNC_(libcharconv_control_characters);
/**
- * Convert characters Xiangqi pieces, with red
+ * Convert characters xiangqi pieces, with red
* as the default colour
*/
LIBCHARCONV_FUNC_(libcharconv_xiangqi_red);
/**
- * Convert characters Xiangqi pieces, with black
+ * Convert characters xiangqi pieces, with black
* as the default colour
*/
LIBCHARCONV_FUNC_(libcharconv_xiangqi_black);
@@ -409,6 +412,44 @@ LIBCHARCONV_FUNC_(libcharconv_xiangqi_black);
*/
LIBCHARCONV_FUNC_(libcharconv_control_character_representations);
+/**
+ * Convert characters xiangqi pieces, with white
+ * as the default colour
+ */
+LIBCHARCONV_FUNC_(libcharconv_chess_white);
+
+/**
+ * Convert characters chess pieces, with black
+ * as the default colour
+ */
+LIBCHARCONV_FUNC_(libcharconv_chess_black);
+
+/**
+ * Convert characters chess pieces, with
+ * neutral colour
+ */
+LIBCHARCONV_FUNC_(libcharconv_chess_neutral);
+
+/**
+ * Rotate characters 45 degrees clockwise
+ */
+LIBCHARCONV_FUNC_(libcharconv_rotated_45deg_cw);
+
+/**
+ * Rotate characters 45 degrees counter-clockwise
+ */
+LIBCHARCONV_FUNC_(libcharconv_rotated_45deg_ccw);
+
+/**
+ * Rotate characters 90 degrees clockwise
+ */
+LIBCHARCONV_FUNC_(libcharconv_rotated_90deg_cw);
+
+/**
+ * Rotate characters 90 degrees counter-clockwise
+ */
+LIBCHARCONV_FUNC_(libcharconv_rotated_90deg_ccw);
+
#undef LIBCHARCONV_FUNC_
#endif
diff --git a/libcharconv_chess_black.c b/libcharconv_chess_black.c
new file mode 100644
index 0000000..906c2f7
--- /dev/null
+++ b/libcharconv_chess_black.c
@@ -0,0 +1,42 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+enum libcharconv_result
+libcharconv_chess_black(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+{
+ uint_least32_t c;
+ *n = 0;
+ for (; slen--; s++) {
+ switch (*s) {
+ case 'K': c = UINT32_C(0x2654); goto conv;
+ case 'Q': c = UINT32_C(0x2655); goto conv;
+ case 'R': c = UINT32_C(0x2656); goto conv;
+ case 'B': c = UINT32_C(0x2657); goto conv;
+ case 'N': c = UINT32_C(0x2658); goto conv;
+ case 'P': c = UINT32_C(0x2659); goto conv;
+ case 'E': c = UINT32_C(0x1FA48); goto conv;
+ case 'k': c = UINT32_C(0x265A); goto conv;
+ case 'q': c = UINT32_C(0x265B); goto conv;
+ case 'r': c = UINT32_C(0x265C); goto conv;
+ case 'b': c = UINT32_C(0x265D); goto conv;
+ case 'n': c = UINT32_C(0x265E); goto conv;
+ case 'p': c = UINT32_C(0x265F); goto conv;
+ case 'e': c = UINT32_C(0x1FA49); goto conv;
+ default:
+ *n += 1u;
+ break;
+ }
+ }
+no_conv:
+ return LIBCHARCONV_NO_CONVERT;
+
+conv:
+ if (*n)
+ goto no_conv;
+ if (*ncp)
+ *cp = c;
+ *n += 1u;
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
+}
diff --git a/libcharconv_chess_neutral.c b/libcharconv_chess_neutral.c
new file mode 100644
index 0000000..04f548d
--- /dev/null
+++ b/libcharconv_chess_neutral.c
@@ -0,0 +1,35 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+enum libcharconv_result
+libcharconv_chess_neutral(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+{
+ uint_least32_t c;
+ *n = 0;
+ for (; slen--; s++) {
+ switch (*s) {
+ case 'k': case 'K': c = UINT32_C(0x1FA00); goto conv;
+ case 'q': case 'Q': c = UINT32_C(0x1FA01); goto conv;
+ case 'r': case 'R': c = UINT32_C(0x1FA02); goto conv;
+ case 'b': case 'B': c = UINT32_C(0x1FA03); goto conv;
+ case 'n': case 'N': c = UINT32_C(0x1FA04); goto conv;
+ case 'p': case 'P': c = UINT32_C(0x1FA05); goto conv;
+ case 'e': case 'E': c = UINT32_C(0x1FA4A); goto conv;
+ default:
+ *n += 1u;
+ break;
+ }
+ }
+no_conv:
+ return LIBCHARCONV_NO_CONVERT;
+
+conv:
+ if (*n)
+ goto no_conv;
+ if (*ncp)
+ *cp = c;
+ *n += 1u;
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
+}
diff --git a/libcharconv_chess_white.c b/libcharconv_chess_white.c
new file mode 100644
index 0000000..1c72e26
--- /dev/null
+++ b/libcharconv_chess_white.c
@@ -0,0 +1,42 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+enum libcharconv_result
+libcharconv_chess_white(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+{
+ uint_least32_t c;
+ *n = 0;
+ for (; slen--; s++) {
+ switch (*s) {
+ case 'k': c = UINT32_C(0x2654); goto conv;
+ case 'q': c = UINT32_C(0x2655); goto conv;
+ case 'r': c = UINT32_C(0x2656); goto conv;
+ case 'b': c = UINT32_C(0x2657); goto conv;
+ case 'n': c = UINT32_C(0x2658); goto conv;
+ case 'p': c = UINT32_C(0x2659); goto conv;
+ case 'e': c = UINT32_C(0x1FA48); goto conv;
+ case 'K': c = UINT32_C(0x265A); goto conv;
+ case 'Q': c = UINT32_C(0x265B); goto conv;
+ case 'R': c = UINT32_C(0x265C); goto conv;
+ case 'B': c = UINT32_C(0x265D); goto conv;
+ case 'N': c = UINT32_C(0x265E); goto conv;
+ case 'P': c = UINT32_C(0x265F); goto conv;
+ case 'E': c = UINT32_C(0x1FA49); goto conv;
+ default:
+ *n += 1u;
+ break;
+ }
+ }
+no_conv:
+ return LIBCHARCONV_NO_CONVERT;
+
+conv:
+ if (*n)
+ goto no_conv;
+ if (*ncp)
+ *cp = c;
+ *n += 1u;
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
+}
diff --git a/libcharconv_flipped.c b/libcharconv_flipped.c
index be18209..2595da8 100644
--- a/libcharconv_flipped.c
+++ b/libcharconv_flipped.c
@@ -6,7 +6,7 @@ static struct {
uint_least32_t a;
uint_least32_t b;
} pairs[] = {
- {0x00A1, 0x0021},
+ {UINT32_C(0x00A1), UINT32_C(0x0021)},
{UINT32_C(0xA4EF), (uint_least32_t)'A'},
{UINT32_C(0xA4D5), (uint_least32_t)'Y'}, /* the one in letterlike is sans-serif */
{UINT32_C(0xA4F5), (uint_least32_t)'U'},
diff --git a/libcharconv_latin.c b/libcharconv_latin.c
index 047dee5..2668ab1 100644
--- a/libcharconv_latin.c
+++ b/libcharconv_latin.c
@@ -460,6 +460,19 @@ libcharconv_latin(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
})[c & 0xFF];
goto conv_str;
+ } else if (UINT32_C(0x2654) <= c && c <= UINT32_C(0x265F)) {
+ /* chess */
+ c = (uint_least32_t)"kqrbnpKQRBNP"[c - UINT32_C(0x2654)];
+ goto conv;
+ } else if (UINT32_C(0x1FA00) <= c && c <= UINT32_C(0x1FA47)) {
+ /* chess */
+ c = (uint_least32_t)"kqrbnpnNnkqrbnpKQRBNP"[(c - UINT32_C(0x1FA00)) % 21u];
+ goto conv;
+ } else if (UINT32_C(0x1FA48) <= c && c <= UINT32_C(0x1FA4D)) {
+ /* chess */
+ c = (uint_least32_t)"eEe"[(c - UINT32_C(0x1FA48)) % 3u];
+ goto conv;
+
} else {
use_switch:
switch (c) {
@@ -655,6 +668,12 @@ libcharconv_latin(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
/* overlaid */
case UINT32_C(0x203D):
case UINT32_C(0x2E18): c1 = '!'; c2 = '?'; goto conv2;
+ case UINT32_C(0x1FA4E): c1 = 'n'; c2 = 'q'; goto conv2;
+ case UINT32_C(0x1FA4F): c1 = 'n'; c2 = 'r'; goto conv2;
+ case UINT32_C(0x1FA50): c1 = 'n'; c2 = 'b'; goto conv2;
+ case UINT32_C(0x1FA51): c1 = 'N'; c2 = 'Q'; goto conv2;
+ case UINT32_C(0x1FA52): c1 = 'N'; c2 = 'R'; goto conv2;
+ case UINT32_C(0x1FA53): c1 = 'N'; c2 = 'B'; goto conv2;
/* joined */
case UINT32_C(0x2048): c1 = '?'; c2 = '!'; goto conv2;
diff --git a/libcharconv_mirrored.c b/libcharconv_mirrored.c
index 9f16569..eecd5f8 100644
--- a/libcharconv_mirrored.c
+++ b/libcharconv_mirrored.c
@@ -6,12 +6,12 @@ static struct {
uint_least32_t a;
uint_least32_t b;
} pairs[] = {
- {0x2032, 0x2035},
- {0x2033, 0x2036},
- {0x2034, 0x2037},
- {0x204F, 0x003B},
- {0x2E2E, 0x003F},
- {0x2143, 0x004C},
+ {UINT32_C(0x2032), UINT32_C(0x2035)},
+ {UINT32_C(0x2033), UINT32_C(0x2036)},
+ {UINT32_C(0x2034), UINT32_C(0x2037)},
+ {UINT32_C(0x204F), UINT32_C(0x003B)},
+ {UINT32_C(0x2E2E), UINT32_C(0x003F)},
+ {UINT32_C(0x2143), UINT32_C(0x004C)},
{UINT32_C(0xA4ED), (uint_least32_t)'B'},
{UINT32_C(0xA4DB), (uint_least32_t)'C'},
{UINT32_C(0xA4F7), (uint_least32_t)'D'},
diff --git a/libcharconv_negative.c b/libcharconv_negative.c
index dfdc353..3bbbccb 100644
--- a/libcharconv_negative.c
+++ b/libcharconv_negative.c
@@ -17,7 +17,13 @@ static struct {
{UINT32_C(0x2616), UINT32_C(0x26C9)},
{UINT32_C(0x2617), UINT32_C(0x26CA)},
{UINT32_C(0x26C0), UINT32_C(0x26C2)},
- {UINT32_C(0x26C1), UINT32_C(0x26C3)}
+ {UINT32_C(0x26C1), UINT32_C(0x26C3)},
+ {UINT32_C(0x1FA06), UINT32_C(0x1FA07)},
+ {UINT32_C(0x1FA1B), UINT32_C(0x1FA1C)},
+ {UINT32_C(0x1FA30), UINT32_C(0x1FA31)},
+ {UINT32_C(0x1FA45), UINT32_C(0x1FA46)},
+ {UINT32_C(0x1FA48), UINT32_C(0x1FA49)},
+ {UINT32_C(0x1FA4B), UINT32_C(0x1FA4C)}
};
@@ -41,12 +47,42 @@ libcharconv_negative(const char *s, size_t slen, size_t *n, uint_least32_t *cp,
continue;
}
- if (UINT32_C(0x1FA60) <= c && c <= UINT32_C(0x1FA66)) {
+ if (UINT32_C(0x2654) <= c && c <= UINT32_C(0x2659)) {
+ c += 6u;
+ goto conv;
+ } else if (UINT32_C(0x265A) <= c && c <= UINT32_C(0x265F)) {
+ c -= 6u;
+ goto conv;
+ } else if (UINT32_C(0x1FA60) <= c && c <= UINT32_C(0x1FA66)) {
c += 7u;
goto conv;
} else if (UINT32_C(0x1FA67) <= c && c <= UINT32_C(0x1FA6D)) {
c -= 7u;
goto conv;
+ } else if (UINT32_C(0x1FA09) <= c && c <= UINT32_C(0x1FA0E)) {
+ c += UINT32_C(0x1FA0F) - UINT32_C(0x1FA09);
+ goto conv;
+ } else if (UINT32_C(0x1FA0F) <= c && c <= UINT32_C(0x1FA14)) {
+ c -= UINT32_C(0x1FA0F) - UINT32_C(0x1FA09);
+ goto conv;
+ } else if (UINT32_C(0x1FA1E) <= c && c <= UINT32_C(0x1FA23)) {
+ c += UINT32_C(0x1FA24) - UINT32_C(0x1FA1E);
+ goto conv;
+ } else if (UINT32_C(0x1FA24) <= c && c <= UINT32_C(0x1FA29)) {
+ c -= UINT32_C(0x1FA24) - UINT32_C(0x1FA1E);
+ goto conv;
+ } else if (UINT32_C(0x1FA33) <= c && c <= UINT32_C(0x1FA38)) {
+ c += UINT32_C(0x1FA39) - UINT32_C(0x1FA33);
+ goto conv;
+ } else if (UINT32_C(0x1FA39) <= c && c <= UINT32_C(0x1FA3E)) {
+ c -= UINT32_C(0x1FA39) - UINT32_C(0x1FA33);
+ goto conv;
+ } else if (UINT32_C(0x1FA4E) <= c && c <= UINT32_C(0x1FA50)) {
+ c += UINT32_C(0x1FA51) - UINT32_C(0x1FA4E);
+ goto conv;
+ } else if (UINT32_C(0x1FA51) <= c && c <= UINT32_C(0x1FA53)) {
+ c -= UINT32_C(0x1FA51) - UINT32_C(0x1FA4E);
+ goto conv;
} else {
for (i = 0u; i < sizeof(pairs) / sizeof(*pairs); i++) {
if (c == pairs[i].a) {
diff --git a/libcharconv_overlaid.c b/libcharconv_overlaid.c
index 7f3cab1..4e8e0f7 100644
--- a/libcharconv_overlaid.c
+++ b/libcharconv_overlaid.c
@@ -7,8 +7,44 @@ static struct {
uint_least32_t b;
uint_least32_t to;
} pairs[] = {
- {0x00BF, 0x00A1, 0x2E18},
- {0x0021, 0x003F, 0x203D}
+ {UINT32_C(0x00BF), UINT32_C(0x00A1), UINT32_C(0x2E18)},
+ {UINT32_C(0x0021), UINT32_C(0x003F), UINT32_C(0x203D)},
+ {UINT32_C(0x1FA06), UINT32_C(0x1FA07), UINT32_C(0x1FA08)},
+ {UINT32_C(0x1FA1B), UINT32_C(0x1FA1C), UINT32_C(0x1FA1D)},
+ {UINT32_C(0x1FA30), UINT32_C(0x1FA31), UINT32_C(0x1FA32)},
+ {UINT32_C(0x1FA45), UINT32_C(0x1FA46), UINT32_C(0x1FA47)},
+ {UINT32_C(0x1FA48), UINT32_C(0x1FA49), UINT32_C(0x1FA4A)},
+ {UINT32_C(0x1FA4B), UINT32_C(0x1FA4C), UINT32_C(0x1FA4D)},
+ {UINT32_C(0x2654), UINT32_C(0x265A), UINT32_C(0x1FA00)},
+ {UINT32_C(0x2655), UINT32_C(0x265B), UINT32_C(0x1FA01)},
+ {UINT32_C(0x2656), UINT32_C(0x265C), UINT32_C(0x1FA02)},
+ {UINT32_C(0x2657), UINT32_C(0x265D), UINT32_C(0x1FA03)},
+ {UINT32_C(0x2658), UINT32_C(0x265E), UINT32_C(0x1FA04)},
+ {UINT32_C(0x2659), UINT32_C(0x265F), UINT32_C(0x1FA05)},
+ {UINT32_C(0x1FA09), UINT32_C(0x1FA0F), UINT32_C(0x1FA15)},
+ {UINT32_C(0x1FA0A), UINT32_C(0x1FA10), UINT32_C(0x1FA16)},
+ {UINT32_C(0x1FA0B), UINT32_C(0x1FA11), UINT32_C(0x1FA17)},
+ {UINT32_C(0x1FA0C), UINT32_C(0x1FA12), UINT32_C(0x1FA18)},
+ {UINT32_C(0x1FA0D), UINT32_C(0x1FA13), UINT32_C(0x1FA19)},
+ {UINT32_C(0x1FA0E), UINT32_C(0x1FA14), UINT32_C(0x1FA1A)},
+ {UINT32_C(0x1FA1E), UINT32_C(0x1FA24), UINT32_C(0x1FA2A)},
+ {UINT32_C(0x1FA1F), UINT32_C(0x1FA25), UINT32_C(0x1FA2B)},
+ {UINT32_C(0x1FA20), UINT32_C(0x1FA26), UINT32_C(0x1FA2C)},
+ {UINT32_C(0x1FA21), UINT32_C(0x1FA27), UINT32_C(0x1FA2D)},
+ {UINT32_C(0x1FA22), UINT32_C(0x1FA28), UINT32_C(0x1FA2E)},
+ {UINT32_C(0x1FA23), UINT32_C(0x1FA29), UINT32_C(0x1FA2F)},
+ {UINT32_C(0x1FA33), UINT32_C(0x1FA39), UINT32_C(0x1FA3F)},
+ {UINT32_C(0x1FA34), UINT32_C(0x1FA3A), UINT32_C(0x1FA40)},
+ {UINT32_C(0x1FA35), UINT32_C(0x1FA3B), UINT32_C(0x1FA41)},
+ {UINT32_C(0x1FA36), UINT32_C(0x1FA3C), UINT32_C(0x1FA42)},
+ {UINT32_C(0x1FA37), UINT32_C(0x1FA3D), UINT32_C(0x1FA43)},
+ {UINT32_C(0x1FA38), UINT32_C(0x1FA3E), UINT32_C(0x1FA44)},
+ {UINT32_C(0x2658), UINT32_C(0x2655), UINT32_C(0x1FA4E)},
+ {UINT32_C(0x2658), UINT32_C(0x2656), UINT32_C(0x1FA4F)},
+ {UINT32_C(0x2658), UINT32_C(0x2657), UINT32_C(0x1FA50)},
+ {UINT32_C(0x265E), UINT32_C(0x265B), UINT32_C(0x1FA51)},
+ {UINT32_C(0x265E), UINT32_C(0x265C), UINT32_C(0x1FA52)},
+ {UINT32_C(0x265E), UINT32_C(0x265D), UINT32_C(0x1FA53)}
};
diff --git a/libcharconv_rotated_45deg_ccw.c b/libcharconv_rotated_45deg_ccw.c
new file mode 100644
index 0000000..7144041
--- /dev/null
+++ b/libcharconv_rotated_45deg_ccw.c
@@ -0,0 +1,78 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+static struct {
+ uint_least32_t to;
+ uint_least32_t from;
+} pairs[] = {
+ {UINT32_C(0x1FA04), UINT32_C(0x1FA08)},
+ {UINT32_C(0x1FA08), UINT32_C(0x1FA19)},
+ {UINT32_C(0x1FA19), UINT32_C(0x1FA1D)},
+ {UINT32_C(0x1FA1D), UINT32_C(0x1FA2E)},
+ {UINT32_C(0x1FA2E), UINT32_C(0x1FA32)},
+ {UINT32_C(0x1FA32), UINT32_C(0x1FA43)},
+ {UINT32_C(0x1FA43), UINT32_C(0x1FA47)},
+ {UINT32_C(0x1FA47), UINT32_C(0x1FA04)},
+ {UINT32_C(0x2658), UINT32_C(0x1FA06)},
+ {UINT32_C(0x1FA06), UINT32_C(0x1FA0D)},
+ {UINT32_C(0x1FA0D), UINT32_C(0x1FA1B)},
+ {UINT32_C(0x1FA1B), UINT32_C(0x1FA22)},
+ {UINT32_C(0x1FA22), UINT32_C(0x1FA30)},
+ {UINT32_C(0x1FA30), UINT32_C(0x1FA37)},
+ {UINT32_C(0x1FA37), UINT32_C(0x1FA45)},
+ {UINT32_C(0x1FA45), UINT32_C(0x2658)},
+ {UINT32_C(0x265E), UINT32_C(0x1FA07)},
+ {UINT32_C(0x1FA07), UINT32_C(0x1FA13)},
+ {UINT32_C(0x1FA13), UINT32_C(0x1FA1C)},
+ {UINT32_C(0x1FA1C), UINT32_C(0x1FA28)},
+ {UINT32_C(0x1FA28), UINT32_C(0x1FA31)},
+ {UINT32_C(0x1FA31), UINT32_C(0x1FA3D)},
+ {UINT32_C(0x1FA3D), UINT32_C(0x1FA46)},
+ {UINT32_C(0x1FA46), UINT32_C(0x265E)}
+};
+
+
+enum libcharconv_result
+libcharconv_rotated_45deg_ccw(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+{
+ uint_least32_t c;
+ size_t i, clen;
+ *n = 0;
+ while (slen) {
+ clen = libcharconv_decode_utf8_(s, slen, &c);
+ if (clen > slen) {
+ if (*n)
+ goto no_conv;
+ return LIBCHARCONV_INDETERMINATE;
+ }
+ if (!clen) {
+ *n += 1u;
+ slen -= 1u;
+ s = &s[1];
+ continue;
+ }
+
+ for (i = 0u; i < sizeof(pairs) / sizeof(*pairs); i++) {
+ if (c == pairs[i].from) {
+ c = pairs[i].to;
+ goto conv;
+ }
+ }
+
+ *n += clen;
+ s = &s[clen];
+ slen -= clen;
+ }
+no_conv:
+ return LIBCHARCONV_NO_CONVERT;
+
+conv:
+ if (*n)
+ goto no_conv;
+ if (*ncp)
+ *cp = c;
+ *n += clen;
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
+}
diff --git a/libcharconv_rotated_45deg_cw.c b/libcharconv_rotated_45deg_cw.c
new file mode 100644
index 0000000..06a4b51
--- /dev/null
+++ b/libcharconv_rotated_45deg_cw.c
@@ -0,0 +1,78 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+static struct {
+ uint_least32_t from;
+ uint_least32_t to;
+} pairs[] = {
+ {UINT32_C(0x1FA04), UINT32_C(0x1FA08)},
+ {UINT32_C(0x1FA08), UINT32_C(0x1FA19)},
+ {UINT32_C(0x1FA19), UINT32_C(0x1FA1D)},
+ {UINT32_C(0x1FA1D), UINT32_C(0x1FA2E)},
+ {UINT32_C(0x1FA2E), UINT32_C(0x1FA32)},
+ {UINT32_C(0x1FA32), UINT32_C(0x1FA43)},
+ {UINT32_C(0x1FA43), UINT32_C(0x1FA47)},
+ {UINT32_C(0x1FA47), UINT32_C(0x1FA04)},
+ {UINT32_C(0x2658), UINT32_C(0x1FA06)},
+ {UINT32_C(0x1FA06), UINT32_C(0x1FA0D)},
+ {UINT32_C(0x1FA0D), UINT32_C(0x1FA1B)},
+ {UINT32_C(0x1FA1B), UINT32_C(0x1FA22)},
+ {UINT32_C(0x1FA22), UINT32_C(0x1FA30)},
+ {UINT32_C(0x1FA30), UINT32_C(0x1FA37)},
+ {UINT32_C(0x1FA37), UINT32_C(0x1FA45)},
+ {UINT32_C(0x1FA45), UINT32_C(0x2658)},
+ {UINT32_C(0x265E), UINT32_C(0x1FA07)},
+ {UINT32_C(0x1FA07), UINT32_C(0x1FA13)},
+ {UINT32_C(0x1FA13), UINT32_C(0x1FA1C)},
+ {UINT32_C(0x1FA1C), UINT32_C(0x1FA28)},
+ {UINT32_C(0x1FA28), UINT32_C(0x1FA31)},
+ {UINT32_C(0x1FA31), UINT32_C(0x1FA3D)},
+ {UINT32_C(0x1FA3D), UINT32_C(0x1FA46)},
+ {UINT32_C(0x1FA46), UINT32_C(0x265E)}
+};
+
+
+enum libcharconv_result
+libcharconv_rotated_45deg_cw(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+{
+ uint_least32_t c;
+ size_t i, clen;
+ *n = 0;
+ while (slen) {
+ clen = libcharconv_decode_utf8_(s, slen, &c);
+ if (clen > slen) {
+ if (*n)
+ goto no_conv;
+ return LIBCHARCONV_INDETERMINATE;
+ }
+ if (!clen) {
+ *n += 1u;
+ slen -= 1u;
+ s = &s[1];
+ continue;
+ }
+
+ for (i = 0u; i < sizeof(pairs) / sizeof(*pairs); i++) {
+ if (c == pairs[i].from) {
+ c = pairs[i].to;
+ goto conv;
+ }
+ }
+
+ *n += clen;
+ s = &s[clen];
+ slen -= clen;
+ }
+no_conv:
+ return LIBCHARCONV_NO_CONVERT;
+
+conv:
+ if (*n)
+ goto no_conv;
+ if (*ncp)
+ *cp = c;
+ *n += clen;
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
+}
diff --git a/libcharconv_rotated_90deg_ccw.c b/libcharconv_rotated_90deg_ccw.c
new file mode 100644
index 0000000..9b7a2e7
--- /dev/null
+++ b/libcharconv_rotated_90deg_ccw.c
@@ -0,0 +1,144 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+static struct {
+ uint_least32_t to;
+ uint_least32_t from;
+} pairs[] = {
+ {UINT32_C(0x1FA04), UINT32_C(0x1FA19)},
+ {UINT32_C(0x1FA19), UINT32_C(0x1FA2E)},
+ {UINT32_C(0x1FA2E), UINT32_C(0x1FA43)},
+ {UINT32_C(0x1FA43), UINT32_C(0x1FA04)},
+ {UINT32_C(0x02658), UINT32_C(0x1FA0D)},
+ {UINT32_C(0x1FA0D), UINT32_C(0x1FA22)},
+ {UINT32_C(0x1FA22), UINT32_C(0x1FA37)},
+ {UINT32_C(0x1FA37), UINT32_C(0x02658)},
+ {UINT32_C(0x0265E), UINT32_C(0x1FA13)},
+ {UINT32_C(0x1FA13), UINT32_C(0x1FA28)},
+ {UINT32_C(0x1FA28), UINT32_C(0x1FA3D)},
+ {UINT32_C(0x1FA3D), UINT32_C(0x0265E)},
+ {UINT32_C(0x1FA08), UINT32_C(0x1FA1D)},
+ {UINT32_C(0x1FA1D), UINT32_C(0x1FA32)},
+ {UINT32_C(0x1FA32), UINT32_C(0x1FA47)},
+ {UINT32_C(0x1FA47), UINT32_C(0x1FA08)},
+ {UINT32_C(0x1FA06), UINT32_C(0x1FA1B)},
+ {UINT32_C(0x1FA1B), UINT32_C(0x1FA30)},
+ {UINT32_C(0x1FA30), UINT32_C(0x1FA45)},
+ {UINT32_C(0x1FA45), UINT32_C(0x1FA06)},
+ {UINT32_C(0x1FA07), UINT32_C(0x1FA1C)},
+ {UINT32_C(0x1FA1C), UINT32_C(0x1FA31)},
+ {UINT32_C(0x1FA31), UINT32_C(0x1FA46)},
+ {UINT32_C(0x1FA46), UINT32_C(0x1FA07)},
+ {UINT32_C(0x1FA48), UINT32_C(0x1FA4B)},
+ {UINT32_C(0x1FA49), UINT32_C(0x1FA4C)},
+ {UINT32_C(0x1FA4A), UINT32_C(0x1FA4D)},
+ {UINT32_C(0x1FA4B), UINT32_C(0x1FA48)},
+ {UINT32_C(0x1FA4C), UINT32_C(0x1FA49)},
+ {UINT32_C(0x1FA4D), UINT32_C(0x1FA4A)},
+ {UINT32_C(0x1FA00), UINT32_C(0x1FA15)},
+ {UINT32_C(0x1FA15), UINT32_C(0x1FA2A)},
+ {UINT32_C(0x1FA2A), UINT32_C(0x1FA3F)},
+ {UINT32_C(0x1FA3F), UINT32_C(0x1FA00)},
+ {UINT32_C(0x1FA01), UINT32_C(0x1FA16)},
+ {UINT32_C(0x1FA16), UINT32_C(0x1FA2B)},
+ {UINT32_C(0x1FA2B), UINT32_C(0x1FA40)},
+ {UINT32_C(0x1FA40), UINT32_C(0x1FA01)},
+ {UINT32_C(0x1FA02), UINT32_C(0x1FA17)},
+ {UINT32_C(0x1FA17), UINT32_C(0x1FA2C)},
+ {UINT32_C(0x1FA2C), UINT32_C(0x1FA41)},
+ {UINT32_C(0x1FA41), UINT32_C(0x1FA02)},
+ {UINT32_C(0x1FA03), UINT32_C(0x1FA18)},
+ {UINT32_C(0x1FA18), UINT32_C(0x1FA2D)},
+ {UINT32_C(0x1FA2D), UINT32_C(0x1FA42)},
+ {UINT32_C(0x1FA42), UINT32_C(0x1FA03)},
+ {UINT32_C(0x1FA05), UINT32_C(0x1FA1A)},
+ {UINT32_C(0x1FA1A), UINT32_C(0x1FA2F)},
+ {UINT32_C(0x1FA2F), UINT32_C(0x1FA44)},
+ {UINT32_C(0x1FA44), UINT32_C(0x1FA05)},
+ {UINT32_C(0x2654), UINT32_C(0x1FA09)},
+ {UINT32_C(0x1FA09), UINT32_C(0x1FA1E)},
+ {UINT32_C(0x1FA1E), UINT32_C(0x1FA33)},
+ {UINT32_C(0x1FA33), UINT32_C(0x2654)},
+ {UINT32_C(0x2655), UINT32_C(0x1FA0A)},
+ {UINT32_C(0x1FA0A), UINT32_C(0x1FA1F)},
+ {UINT32_C(0x1FA1F), UINT32_C(0x1FA34)},
+ {UINT32_C(0x1FA34), UINT32_C(0x2655)},
+ {UINT32_C(0x2656), UINT32_C(0x1FA0B)},
+ {UINT32_C(0x1FA0B), UINT32_C(0x1FA20)},
+ {UINT32_C(0x1FA20), UINT32_C(0x1FA35)},
+ {UINT32_C(0x1FA35), UINT32_C(0x2656)},
+ {UINT32_C(0x2657), UINT32_C(0x1FA0C)},
+ {UINT32_C(0x1FA0C), UINT32_C(0x1FA21)},
+ {UINT32_C(0x1FA21), UINT32_C(0x1FA36)},
+ {UINT32_C(0x1FA36), UINT32_C(0x2657)},
+ {UINT32_C(0x2659), UINT32_C(0x1FA0E)},
+ {UINT32_C(0x1FA0E), UINT32_C(0x1FA23)},
+ {UINT32_C(0x1FA23), UINT32_C(0x1FA38)},
+ {UINT32_C(0x1FA38), UINT32_C(0x2659)},
+ {UINT32_C(0x265A), UINT32_C(0x1FA0F)},
+ {UINT32_C(0x1FA0F), UINT32_C(0x1FA24)},
+ {UINT32_C(0x1FA24), UINT32_C(0x1FA39)},
+ {UINT32_C(0x1FA39), UINT32_C(0x265A)},
+ {UINT32_C(0x265B), UINT32_C(0x1FA10)},
+ {UINT32_C(0x1FA10), UINT32_C(0x1FA25)},
+ {UINT32_C(0x1FA25), UINT32_C(0x1FA3A)},
+ {UINT32_C(0x1FA3A), UINT32_C(0x265B)},
+ {UINT32_C(0x265C), UINT32_C(0x1FA11)},
+ {UINT32_C(0x1FA11), UINT32_C(0x1FA26)},
+ {UINT32_C(0x1FA26), UINT32_C(0x1FA3B)},
+ {UINT32_C(0x1FA3B), UINT32_C(0x265C)},
+ {UINT32_C(0x265D), UINT32_C(0x1FA12)},
+ {UINT32_C(0x1FA12), UINT32_C(0x1FA27)},
+ {UINT32_C(0x1FA27), UINT32_C(0x1FA3C)},
+ {UINT32_C(0x1FA3C), UINT32_C(0x265D)},
+ {UINT32_C(0x265F), UINT32_C(0x1FA14)},
+ {UINT32_C(0x1FA14), UINT32_C(0x1FA29)},
+ {UINT32_C(0x1FA29), UINT32_C(0x1FA3E)},
+ {UINT32_C(0x1FA3E), UINT32_C(0x265F)}
+};
+
+
+enum libcharconv_result
+libcharconv_rotated_90deg_ccw(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+{
+ uint_least32_t c;
+ size_t i, clen;
+ *n = 0;
+ while (slen) {
+ clen = libcharconv_decode_utf8_(s, slen, &c);
+ if (clen > slen) {
+ if (*n)
+ goto no_conv;
+ return LIBCHARCONV_INDETERMINATE;
+ }
+ if (!clen) {
+ *n += 1u;
+ slen -= 1u;
+ s = &s[1];
+ continue;
+ }
+
+ for (i = 0u; i < sizeof(pairs) / sizeof(*pairs); i++) {
+ if (c == pairs[i].from) {
+ c = pairs[i].to;
+ goto conv;
+ }
+ }
+
+ *n += clen;
+ s = &s[clen];
+ slen -= clen;
+ }
+no_conv:
+ return LIBCHARCONV_NO_CONVERT;
+
+conv:
+ if (*n)
+ goto no_conv;
+ if (*ncp)
+ *cp = c;
+ *n += clen;
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
+}
diff --git a/libcharconv_rotated_90deg_cw.c b/libcharconv_rotated_90deg_cw.c
new file mode 100644
index 0000000..68cf9b7
--- /dev/null
+++ b/libcharconv_rotated_90deg_cw.c
@@ -0,0 +1,144 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+static struct {
+ uint_least32_t from;
+ uint_least32_t to;
+} pairs[] = {
+ {UINT32_C(0x1FA04), UINT32_C(0x1FA19)},
+ {UINT32_C(0x1FA19), UINT32_C(0x1FA2E)},
+ {UINT32_C(0x1FA2E), UINT32_C(0x1FA43)},
+ {UINT32_C(0x1FA43), UINT32_C(0x1FA04)},
+ {UINT32_C(0x02658), UINT32_C(0x1FA0D)},
+ {UINT32_C(0x1FA0D), UINT32_C(0x1FA22)},
+ {UINT32_C(0x1FA22), UINT32_C(0x1FA37)},
+ {UINT32_C(0x1FA37), UINT32_C(0x02658)},
+ {UINT32_C(0x0265E), UINT32_C(0x1FA13)},
+ {UINT32_C(0x1FA13), UINT32_C(0x1FA28)},
+ {UINT32_C(0x1FA28), UINT32_C(0x1FA3D)},
+ {UINT32_C(0x1FA3D), UINT32_C(0x0265E)},
+ {UINT32_C(0x1FA08), UINT32_C(0x1FA1D)},
+ {UINT32_C(0x1FA1D), UINT32_C(0x1FA32)},
+ {UINT32_C(0x1FA32), UINT32_C(0x1FA47)},
+ {UINT32_C(0x1FA47), UINT32_C(0x1FA08)},
+ {UINT32_C(0x1FA06), UINT32_C(0x1FA1B)},
+ {UINT32_C(0x1FA1B), UINT32_C(0x1FA30)},
+ {UINT32_C(0x1FA30), UINT32_C(0x1FA45)},
+ {UINT32_C(0x1FA45), UINT32_C(0x1FA06)},
+ {UINT32_C(0x1FA07), UINT32_C(0x1FA1C)},
+ {UINT32_C(0x1FA1C), UINT32_C(0x1FA31)},
+ {UINT32_C(0x1FA31), UINT32_C(0x1FA46)},
+ {UINT32_C(0x1FA46), UINT32_C(0x1FA07)},
+ {UINT32_C(0x1FA48), UINT32_C(0x1FA4B)},
+ {UINT32_C(0x1FA49), UINT32_C(0x1FA4C)},
+ {UINT32_C(0x1FA4A), UINT32_C(0x1FA4D)},
+ {UINT32_C(0x1FA4B), UINT32_C(0x1FA48)},
+ {UINT32_C(0x1FA4C), UINT32_C(0x1FA49)},
+ {UINT32_C(0x1FA4D), UINT32_C(0x1FA4A)},
+ {UINT32_C(0x1FA00), UINT32_C(0x1FA15)},
+ {UINT32_C(0x1FA15), UINT32_C(0x1FA2A)},
+ {UINT32_C(0x1FA2A), UINT32_C(0x1FA3F)},
+ {UINT32_C(0x1FA3F), UINT32_C(0x1FA00)},
+ {UINT32_C(0x1FA01), UINT32_C(0x1FA16)},
+ {UINT32_C(0x1FA16), UINT32_C(0x1FA2B)},
+ {UINT32_C(0x1FA2B), UINT32_C(0x1FA40)},
+ {UINT32_C(0x1FA40), UINT32_C(0x1FA01)},
+ {UINT32_C(0x1FA02), UINT32_C(0x1FA17)},
+ {UINT32_C(0x1FA17), UINT32_C(0x1FA2C)},
+ {UINT32_C(0x1FA2C), UINT32_C(0x1FA41)},
+ {UINT32_C(0x1FA41), UINT32_C(0x1FA02)},
+ {UINT32_C(0x1FA03), UINT32_C(0x1FA18)},
+ {UINT32_C(0x1FA18), UINT32_C(0x1FA2D)},
+ {UINT32_C(0x1FA2D), UINT32_C(0x1FA42)},
+ {UINT32_C(0x1FA42), UINT32_C(0x1FA03)},
+ {UINT32_C(0x1FA05), UINT32_C(0x1FA1A)},
+ {UINT32_C(0x1FA1A), UINT32_C(0x1FA2F)},
+ {UINT32_C(0x1FA2F), UINT32_C(0x1FA44)},
+ {UINT32_C(0x1FA44), UINT32_C(0x1FA05)},
+ {UINT32_C(0x2654), UINT32_C(0x1FA09)},
+ {UINT32_C(0x1FA09), UINT32_C(0x1FA1E)},
+ {UINT32_C(0x1FA1E), UINT32_C(0x1FA33)},
+ {UINT32_C(0x1FA33), UINT32_C(0x2654)},
+ {UINT32_C(0x2655), UINT32_C(0x1FA0A)},
+ {UINT32_C(0x1FA0A), UINT32_C(0x1FA1F)},
+ {UINT32_C(0x1FA1F), UINT32_C(0x1FA34)},
+ {UINT32_C(0x1FA34), UINT32_C(0x2655)},
+ {UINT32_C(0x2656), UINT32_C(0x1FA0B)},
+ {UINT32_C(0x1FA0B), UINT32_C(0x1FA20)},
+ {UINT32_C(0x1FA20), UINT32_C(0x1FA35)},
+ {UINT32_C(0x1FA35), UINT32_C(0x2656)},
+ {UINT32_C(0x2657), UINT32_C(0x1FA0C)},
+ {UINT32_C(0x1FA0C), UINT32_C(0x1FA21)},
+ {UINT32_C(0x1FA21), UINT32_C(0x1FA36)},
+ {UINT32_C(0x1FA36), UINT32_C(0x2657)},
+ {UINT32_C(0x2659), UINT32_C(0x1FA0E)},
+ {UINT32_C(0x1FA0E), UINT32_C(0x1FA23)},
+ {UINT32_C(0x1FA23), UINT32_C(0x1FA38)},
+ {UINT32_C(0x1FA38), UINT32_C(0x2659)},
+ {UINT32_C(0x265A), UINT32_C(0x1FA0F)},
+ {UINT32_C(0x1FA0F), UINT32_C(0x1FA24)},
+ {UINT32_C(0x1FA24), UINT32_C(0x1FA39)},
+ {UINT32_C(0x1FA39), UINT32_C(0x265A)},
+ {UINT32_C(0x265B), UINT32_C(0x1FA10)},
+ {UINT32_C(0x1FA10), UINT32_C(0x1FA25)},
+ {UINT32_C(0x1FA25), UINT32_C(0x1FA3A)},
+ {UINT32_C(0x1FA3A), UINT32_C(0x265B)},
+ {UINT32_C(0x265C), UINT32_C(0x1FA11)},
+ {UINT32_C(0x1FA11), UINT32_C(0x1FA26)},
+ {UINT32_C(0x1FA26), UINT32_C(0x1FA3B)},
+ {UINT32_C(0x1FA3B), UINT32_C(0x265C)},
+ {UINT32_C(0x265D), UINT32_C(0x1FA12)},
+ {UINT32_C(0x1FA12), UINT32_C(0x1FA27)},
+ {UINT32_C(0x1FA27), UINT32_C(0x1FA3C)},
+ {UINT32_C(0x1FA3C), UINT32_C(0x265D)},
+ {UINT32_C(0x265F), UINT32_C(0x1FA14)},
+ {UINT32_C(0x1FA14), UINT32_C(0x1FA29)},
+ {UINT32_C(0x1FA29), UINT32_C(0x1FA3E)},
+ {UINT32_C(0x1FA3E), UINT32_C(0x265F)}
+};
+
+
+enum libcharconv_result
+libcharconv_rotated_90deg_cw(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+{
+ uint_least32_t c;
+ size_t i, clen;
+ *n = 0;
+ while (slen) {
+ clen = libcharconv_decode_utf8_(s, slen, &c);
+ if (clen > slen) {
+ if (*n)
+ goto no_conv;
+ return LIBCHARCONV_INDETERMINATE;
+ }
+ if (!clen) {
+ *n += 1u;
+ slen -= 1u;
+ s = &s[1];
+ continue;
+ }
+
+ for (i = 0u; i < sizeof(pairs) / sizeof(*pairs); i++) {
+ if (c == pairs[i].from) {
+ c = pairs[i].to;
+ goto conv;
+ }
+ }
+
+ *n += clen;
+ s = &s[clen];
+ slen -= clen;
+ }
+no_conv:
+ return LIBCHARCONV_NO_CONVERT;
+
+conv:
+ if (*n)
+ goto no_conv;
+ if (*ncp)
+ *cp = c;
+ *n += clen;
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
+}
diff --git a/libcharconv_turned.c b/libcharconv_turned.c
index 33b8a31..2ff3e5a 100644
--- a/libcharconv_turned.c
+++ b/libcharconv_turned.c
@@ -6,14 +6,14 @@ static struct {
uint_least32_t a;
uint_least32_t b;
} pairs[] = {
- {0x0032, 0x218A},
- {0x0033, 0x218B},
- {0x2616, 0x26C9},
- {0x2617, 0x26CA},
- {0x0021, 0x00A1},
- {0x003F, 0x00BF},
- {0x2E35, 0x003B},
- {0x203D, 0x2E18},
+ {UINT32_C(0x0032), UINT32_C(0x218A)},
+ {UINT32_C(0x0033), UINT32_C(0x218B)},
+ {UINT32_C(0x2616), UINT32_C(0x26C9)},
+ {UINT32_C(0x2617), UINT32_C(0x26CA)},
+ {UINT32_C(0x0021), UINT32_C(0x00A1)},
+ {UINT32_C(0x003F), UINT32_C(0x00BF)},
+ {UINT32_C(0x2E35), UINT32_C(0x003B)},
+ {UINT32_C(0x203D), UINT32_C(0x2E18)},
{UINT32_C(0xA4EF), (uint_least32_t)'A'},
{UINT32_C(0xA4ED), (uint_least32_t)'B'},
{UINT32_C(0xA4DB), (uint_least32_t)'C'},
@@ -57,7 +57,19 @@ libcharconv_turned(const char *s, size_t slen, size_t *n, uint_least32_t *cp, si
continue;
}
- if (UINT32_C(0x1F031) <= c && c <= UINT32_C(0x1F061)) {
+ if (UINT32_C(0x1FA00) <= c && c <= UINT32_C(0x1FA1D)) {
+ c += 0x2Au;
+ goto conv;
+ } else if (UINT32_C(0x1FA2A) <= c && c <= UINT32_C(0x1FA47)) {
+ c -= 0x2Au;
+ goto conv;
+ } else if (UINT32_C(0x1FA1E) <= c && c <= UINT32_C(0x1FA29)) {
+ c -= UINT32_C(0x1FA1E) - UINT32_C(0x2654);
+ goto conv;
+ } else if (UINT32_C(0x2654) <= c && c <= UINT32_C(0x265F)) {
+ c += UINT32_C(0x1FA1E) - UINT32_C(0x2654);
+ goto conv;
+ } else if (UINT32_C(0x1F031) <= c && c <= UINT32_C(0x1F061)) {
c -= UINT32_C(0x1F031);
c = c % 7u * 7u + c / 7u;
c += UINT32_C(0x1F031);