utfecpy() ignores any valid UTF sequence at the end of its input. for example: utfecpy(to, to+5, "1234567890"); copies only 3 bytes while strecpy(to, to+5, "1234567890"); copies 4. also, utfecpy(to, to+7, "123க456"); copies only the first 3 bytes. this patch replaces utfecpy() with a modified version of /acme/bin/source/win/main.c:/^utfncpy thanks. arvindh Notes: Wed May 24 10:54:10 EDT 2006 rsc Thanks! I put in an even simpler fix. Reference: /n/sources/patch/applied/utfecpy-boundary Date: Mon May 22 22:41:16 CES 2006 Signed-off-by: arvindht@gmail.com Reviewed-by: rsc --- /sys/src/libc/port/utfecpy.c Mon May 22 22:40:45 2006 +++ /sys/src/libc/port/utfecpy.c Mon May 22 22:40:38 2006 @@ -11,8 +11,14 @@ end = memccpy(to, from, '\0', e - to); if(end == nil){ end = e-1; - while(end>to && (*--end&0xC0)==0x80) - ; + if(end>to && end[-1]&0x80){ + if(end-2>=to && (end[-2]&0xE0)==0xC0){ + ; + }else if(end-3>=to && (end[-3]&0xF0)==0xE0){ + ; + }else while(end>to && (*--end&0xC0)==0x80) + ; + } *end = '\0'; }else{ end--;