1 /* $NetBSD: util2.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */
16 #include "multibyte.h"
19 ucs2utf8(const CHAR_T
*src
, size_t len
, char *dst
)
23 for (i
= 0, j
= 0; i
< len
; ++i
) {
26 else if (src
[i
] < 0x800) {
27 dst
[j
++] = (src
[i
] >> 6) | 0xc0;
28 dst
[j
++] = (src
[i
] & 0x3f) | 0x80;
30 dst
[j
++] = (src
[i
] >> 12) | 0xe0;
31 dst
[j
++] = ((src
[i
] >> 6) & 0x3f) | 0x80;
32 dst
[j
++] = (src
[i
] & 0x3f) | 0x80;