summaryrefslogtreecommitdiff
path: root/src/htscharset.c
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2013-05-30 17:46:46 +0000
committerXavier Roche <xroche@users.noreply.github.com>2013-05-30 17:46:46 +0000
commit01af2a5e73f53ebf8a092e4bda77cd1326c1da11 (patch)
tree5e5aa62a7472005bae2ba92b1b2b4df154ccf244 /src/htscharset.c
parentc842d0591d1bf5be7a6375393967d2525b0e92d8 (diff)
Added hts_writeUTF8()
Diffstat (limited to 'src/htscharset.c')
-rw-r--r--src/htscharset.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/htscharset.c b/src/htscharset.c
index 1de7c61..932c01e 100644
--- a/src/htscharset.c
+++ b/src/htscharset.c
@@ -1156,6 +1156,20 @@ char *hts_convertUCS4StringToUTF8(const hts_UCS4 *s, size_t nChars) {
return dest;
}
+size_t hts_writeUTF8(hts_UCS4 uc, char *dest, size_t size) {
+ size_t offs = 0;
+#define EM(C) do { \
+ if (offs + 1 < size) { \
+ dest[offs++] = C; \
+ } else { \
+ return 0; \
+ } \
+} while(0)
+ EMIT_UNICODE(uc, EM);
+#undef EM
+ return offs;
+}
+
size_t hts_stringLengthUCS4(const hts_UCS4 *s) {
size_t i;
for(i = 0 ; s[i] != 0 ; i++) ;