Remove building with NOCRYPTO option
[minix.git] / external / bsd / nvi / dist / common / util2.c
blob628ae4e416f56bd5f100fc89fb49d2d87070d556
1 /* $NetBSD: util2.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */
2 #include "config.h"
4 #include <sys/types.h>
5 #include <sys/queue.h>
6 #include <sys/time.h>
8 #include <bitstring.h>
9 #include <errno.h>
10 #include <limits.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <unistd.h>
16 #include "multibyte.h"
18 int
19 ucs2utf8(const CHAR_T *src, size_t len, char *dst)
21 int i, j;
23 for (i = 0, j = 0; i < len; ++i) {
24 if (src[i] < 0x80)
25 dst[j++] = src[i];
26 else if (src[i] < 0x800) {
27 dst[j++] = (src[i] >> 6) | 0xc0;
28 dst[j++] = (src[i] & 0x3f) | 0x80;
29 } else {
30 dst[j++] = (src[i] >> 12) | 0xe0;
31 dst[j++] = ((src[i] >> 6) & 0x3f) | 0x80;
32 dst[j++] = (src[i] & 0x3f) | 0x80;
36 return j;