The R Project SVN R

Rev

Rev 59096 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 59096 Rev 78227
Line 64... Line 64...
64
*/
64
*/
65
 
65
 
66
static int
66
static int
67
valid_utf8(const char *string, size_t length) // R change int->size_t
67
valid_utf8(const char *string, size_t length) // R change int->size_t
68
{
68
{
69
    const char *p;
69
    const unsigned char *p;
70
 
70
 
71
    for (p = string; length-- > 0; p++) {
71
    for (p = (unsigned char *)string; length-- > 0; p++) {
72
	int ab, c, d;
72
	unsigned ab, c, d;
73
	c = (unsigned char)*p;
73
	c = *p;
74
	if (c < 128) continue;                /* ASCII character */
74
	if (c < 128) continue;                /* ASCII character */
75
	if (c < 0xc0) return 1;               /* Isolated 10xx xxxx byte */
75
	if (c < 0xc0) return 1;               /* Isolated 10xx xxxx byte */
76
	if (c >= 0xfe) return 1;             /* Invalid 0xfe or 0xff bytes */
76
	if (c >= 0xfe) return 1;             /* Invalid 0xfe or 0xff bytes */
77
 
77
 
78
	ab = utf8_table4[c & 0x3f];     /* Number of additional bytes */
78
	ab = utf8_table4[c & 0x3f];     /* Number of additional bytes */