mirror of
https://github.com/0intro/conterm
synced 2024-11-25 23:19:36 +03:00
22 lines
284 B
C
22 lines
284 B
C
#include <u.h>
|
|
#include <libc.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;
|
|
}
|