From 37da2899f40661e3e9631e497da8dc59b971cbd0 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Fri, 22 Dec 2006 17:07:39 +0000 Subject: 20060303a --- libkern/utfecpy.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 libkern/utfecpy.c (limited to 'libkern/utfecpy.c') diff --git a/libkern/utfecpy.c b/libkern/utfecpy.c new file mode 100644 index 00000000..8ccb841c --- /dev/null +++ b/libkern/utfecpy.c @@ -0,0 +1,20 @@ +#include "lib9.h" + +char* +utfecpy(char *to, char *e, char *from) +{ + char *end; + + if(to >= e) + return to; + end = memccpy(to, from, '\0', e - to); + if(end == nil){ + end = e-1; + while(end>to && (*--end&0xC0)==0x80) + ; + *end = '\0'; + }else{ + end--; + } + return end; +} -- cgit v1.2.3