blob: d44c9e62dcd4e56d9753d90859cecafb05a3db21 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include "internal.h"
/* returns 1 if string of length n is long enough to be decoded */
int
utf8ยทcanfit(byte* s, int n)
{
int i;
rune c;
if(n <= 0) return 0;
c = *(ubyte*) s;
if(c < Tx) return 1;
for(i = 3; i < UTFmax + 1; i++){
if(c < Tbyte(i))
return n >= i - 1;
}
return n >= UTFmax;
}
|