#include <stdbool.h>
#ifndef REGTEST
#include <uchar.h>
+#include <_PDCLIB_encoding.h>
static bool asciitoc32(
char32_t **restrict p_outbuf,
{
while(*p_outsz && *p_insz) {
unsigned char c = **p_inbuf;
- if(c > 128)
+ if(c > 127)
return false;
- **p_outbuf = c;
+
+ if(p_outbuf) {
+ **p_outbuf = c;
+ (*p_outbuf)++;
+ }
(*p_inbuf)++;
- (*p_outbuf)++;
(*p_insz)--;
(*p_outsz)--;
}
{
while(*p_outsz && *p_insz) {
char32_t c = **p_inbuf;
- if(c > 128)
+ if(c > 127)
return false;
- **p_outbuf = c;
+
+ if(p_outbuf) {
+ **p_outbuf = c;
+ (*p_outbuf)++;
+ }
(*p_inbuf)++;
- (*p_outbuf)++;
(*p_insz)--;
(*p_outsz)--;
}
return true;
}
+
+_PDCLIB_charcodec_t _PDCLIB_ascii_codec = {
+ .__mbstoc32s = asciitoc32,
+ .__c32stombs = c32toascii,
+};
+
#endif
#ifdef TEST