mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 03:28:19 +00:00
C90
This commit is contained in:
parent
92d08d07de
commit
a3a363f665
|
@ -3184,12 +3184,13 @@ int str_utf8_check(const char *str)
|
||||||
|
|
||||||
void str_utf8_copy(char *dst, const char *src, int dst_size)
|
void str_utf8_copy(char *dst, const char *src, int dst_size)
|
||||||
{
|
{
|
||||||
strncpy(dst, src, dst_size);
|
|
||||||
dst[dst_size-1] = 0; /* assure null termination */
|
|
||||||
|
|
||||||
// check whether we need to remove a broken utf8 character
|
|
||||||
char *end = dst + (dst_size-2);
|
char *end = dst + (dst_size-2);
|
||||||
char *ptr = end;
|
char *ptr = end;
|
||||||
|
|
||||||
|
strncpy(dst, src, dst_size);
|
||||||
|
dst[dst_size-1] = 0;
|
||||||
|
|
||||||
|
// check whether we need to remove a broken utf8 character
|
||||||
while(ptr > dst)
|
while(ptr > dst)
|
||||||
{
|
{
|
||||||
if((*ptr&0xC0) == 0x80)
|
if((*ptr&0xC0) == 0x80)
|
||||||
|
|
Loading…
Reference in a new issue