utf8_decode_char2(): fix return value
The return value of utf8_decode_char2() was 0, not (wchar_t)-1 as stated in the documentation. Fix it.
This commit is contained in:
parent
f2569b9423
commit
b04ebb80e6
|
@ -24,7 +24,7 @@ utf8_decode_char2(const char* src, size_t size, size_t* used)
|
|||
|
||||
if(!src || !size) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
return (wchar_t)-1;
|
||||
}
|
||||
if(used) *used = 1;
|
||||
ch = *src++;
|
||||
|
@ -57,18 +57,18 @@ utf8_decode_char2(const char* src, size_t size, size_t* used)
|
|||
ret = ch & 0x01;
|
||||
} else {
|
||||
errno = EILSEQ;
|
||||
return 0;
|
||||
return (wchar_t)-1;
|
||||
}
|
||||
|
||||
while(remain--) {
|
||||
if(!--size) {
|
||||
errno = EILSEQ;
|
||||
return 0;
|
||||
return (wchar_t)-1;
|
||||
}
|
||||
ch = *src++;
|
||||
if((ch & 0xC0) != 0x80) {
|
||||
errno = EILSEQ;
|
||||
return 0;
|
||||
return (wchar_t)-1;
|
||||
}
|
||||
ret <<= 6;
|
||||
ret |= ch & 0x3F;
|
||||
|
@ -76,7 +76,7 @@ utf8_decode_char2(const char* src, size_t size, size_t* used)
|
|||
|
||||
if(ret < min) {
|
||||
errno = EILSEQ;
|
||||
return 0;
|
||||
return (wchar_t)-1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -104,7 +104,7 @@ utf8_decode_char2_force(const char* src, size_t size, size_t* used,
|
|||
|
||||
if(!src || !size) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
return (wchar_t)-1;
|
||||
}
|
||||
if(used) *used = 1;
|
||||
ch = *src++;
|
||||
|
@ -143,7 +143,7 @@ utf8_decode_char2_force(const char* src, size_t size, size_t* used,
|
|||
ret |= ch & 0x3F;
|
||||
}
|
||||
|
||||
if(ch < min) goto ILSEQ;
|
||||
if(ret < min) goto ILSEQ;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue