*/
#include "lib/lib.h"
-#include "lib/mempool.h"
#include "charset/mp-charconv.h"
#include <string.h>
#include <alloca.h>
byte *
-mp_conv(struct mempool *mp, byte *s, uns in_cs, uns out_cs)
+mp_strconv(struct mempool *mp, byte *s, uns in_cs, uns out_cs)
{
if (in_cs == out_cs)
return mp_strdup(mp, s);
#include "lib/mempool.h"
#include "charset/charconv.h"
-byte *mp_conv(struct mempool *mp, byte *s, uns cs_in, uns cs_out);
+byte *mp_strconv(struct mempool *mp, byte *s, uns cs_in, uns cs_out);
static inline byte *
-mp_conv_to_utf8(struct mempool *mp, byte *s, uns cs_in)
-{ return mp_conv(mp, s, cs_in, CONV_CHARSET_UTF8); }
+mp_strconv_to_utf8(struct mempool *mp, byte *s, uns cs_in)
+{ return mp_strconv(mp, s, cs_in, CONV_CHARSET_UTF8); }
static inline byte *
-mp_conv_from_utf8(struct mempool *mp, byte *s, uns cs_out)
-{ return mp_conv(mp, s, CONV_CHARSET_UTF8, cs_out); }
+mp_strconv_from_utf8(struct mempool *mp, byte *s, uns cs_out)
+{ return mp_strconv(mp, s, CONV_CHARSET_UTF8, cs_out); }
#endif
#define INITIAL_SCALE 2
uns
-stk_conv_init(struct conv_context *c, byte *s, uns in_cs, uns out_cs)
+stk_strconv_init(struct conv_context *c, byte *s, uns in_cs, uns out_cs)
{
uns l = strlen(s);
if (in_cs == out_cs)
}
uns
-stk_conv_step(struct conv_context *c, byte *buf, uns len)
+stk_strconv_step(struct conv_context *c, byte *buf, uns len)
{
if (!c->source_end)
{
/* The following macros convert strings between given charsets (CONV_CHARSET_x). */
-#define stk_conv(s, cs_in, cs_out) \
- ({ struct conv_context _c; uns _l=stk_conv_init(&_c, (s), (cs_in), (cs_out)); \
- while (_l) _l=stk_conv_step(&_c, alloca(_l), _l); _c.dest_start; })
+#define stk_strconv(s, cs_in, cs_out) \
+ ({ struct conv_context _c; uns _l=stk_strconv_init(&_c, (s), (cs_in), (cs_out)); \
+ while (_l) _l=stk_strconv_step(&_c, alloca(_l), _l); _c.dest_start; })
-#define stk_conv_to_utf8(s, cs_in) stk_conv(s, cs_in, CONV_CHARSET_UTF8)
-#define stk_conv_from_utf8(s, cs_out) stk_conv(s, CONV_CHARSET_UTF8, cs_out)
+#define stk_strconv_to_utf8(s, cs_in) stk_strconv(s, cs_in, CONV_CHARSET_UTF8)
+#define stk_strconv_from_utf8(s, cs_out) stk_strconv(s, CONV_CHARSET_UTF8, cs_out)
/* Internals */
-uns stk_conv_init(struct conv_context *c, byte *s, uns cs_in, uns cs_out);
-uns stk_conv_step(struct conv_context *c, byte *buf, uns len);
+uns stk_strconv_init(struct conv_context *c, byte *s, uns cs_in, uns cs_out);
+uns stk_strconv_step(struct conv_context *c, byte *buf, uns len);
#endif