1
0
forked from GitHub/gf-core

clean up the UTF8 API in libgu

This commit is contained in:
kr.angelov
2013-09-13 07:44:45 +00:00
parent c684ab30a7
commit c469ae9091
3 changed files with 5 additions and 56 deletions

View File

@@ -253,7 +253,7 @@ gu_putc(char c, GuOut* out, GuExn* err);
void
gu_puts(const char* str, GuOut* out, GuExn* err)
{
gu_str_out_utf8(str, out, err);
gu_out_bytes(out, (const uint8_t*) str, strlen(str), err);
}
void
@@ -261,7 +261,7 @@ gu_vprintf(const char* fmt, va_list args, GuOut* out, GuExn* err)
{
GuPool* tmp_pool = gu_local_pool();
char* str = gu_vasprintf(fmt, args, tmp_pool);
gu_str_out_utf8(str, out, err);
gu_out_bytes(out, (const uint8_t*) str, strlen(str), err);
gu_pool_free(tmp_pool);
}

View File

@@ -97,25 +97,8 @@ gu_advance_utf8(GuUCS ucs, uint8_t* buf)
}
}
char
gu_in_utf8_char_(GuIn* in, GuExn* err)
{
return gu_ucs_char(gu_in_utf8(in, err), err);
}
char
gu_in_utf8_char(GuIn* in, GuExn* err)
{
int i = gu_in_peek_u8(in);
if (i >= 0 && i < 0x80) {
gu_in_consume(in, 1);
return (char) i;
}
return gu_in_utf8_char_(in, err);
}
void
gu_out_utf8_long_(GuUCS ucs, GuOut* out, GuExn* err)
gu_out_utf8_(GuUCS ucs, GuOut* out, GuExn* err)
{
uint8_t buf[4];
size_t sz = gu_advance_utf8(ucs, buf);
@@ -173,27 +156,5 @@ gu_utf32_out_utf8_buffered_(const GuUCS* src, size_t len, GuOut* out,
return src_i;
}
size_t
gu_utf32_out_utf8(const GuUCS* src, size_t len, GuOut* out, GuExn* err)
{
if (gu_out_is_buffered(out)) {
return gu_utf32_out_utf8_buffered_(src, len, out, err);
}
for (size_t i = 0; i < len; i++) {
gu_out_utf8(src[i], out, err);
if (!gu_ok(err)) {
return i;
}
}
return len;
}
extern inline GuUCS
gu_in_utf8(GuIn* in, GuExn* err);
void
gu_str_out_utf8(const char* str, GuOut* out, GuExn* err)
{
gu_out_bytes(out, (const uint8_t*) str, strlen(str), err);
}

View File

@@ -17,13 +17,6 @@ gu_in_utf8(GuIn* in, GuExn* err)
return gu_in_utf8_(in, err);
}
char
gu_in_utf8_char(GuIn* in, GuExn* err);
void
gu_out_utf8_long_(GuUCS ucs, GuOut* out, GuExn* err);
inline void
gu_out_utf8(GuUCS ucs, GuOut* out, GuExn* err)
{
@@ -31,17 +24,12 @@ gu_out_utf8(GuUCS ucs, GuOut* out, GuExn* err)
if (GU_LIKELY(ucs < 0x80)) {
gu_out_u8(out, ucs, err);
} else {
gu_out_utf8_long_(ucs, out, err);
extern void gu_out_utf8_(GuUCS ucs, GuOut* out, GuExn* err);
gu_out_utf8_(ucs, out, err);
}
}
size_t
gu_utf32_out_utf8(const GuUCS* src, size_t len, GuOut* out, GuExn* err);
GuUCS
gu_utf8_decode(const uint8_t** utf8);
void
gu_str_out_utf8(const char* str, GuOut* out, GuExn* err);
#endif // GU_UTF8_H_