515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
|
if( c&0x10 ){
/* Unicode characters > U+FFFF are not supported.
* Windows XP and earlier cannot handle them.
*/
return 0;
}
/* This is a 3-byte UTF-8 character */
unicode = ((c&0x0f)<<12) + ((c&0x3f)<<6) + (c&0x3f);
if( unicode <= 0x07ff ){
/* overlong form */
return 0;
}else if( unicode>=0xe000 ){
/* U+E000..U+FFFF */
if( (unicode<=0xf8ff) || (unicode>=0xfffe) ){
/* U+E000..U+F8FF are for private use.
* U+FFFE..U+FFFF are noncharacters. */
return 0;
} else if( (unicode>=0xfdd0) && (unicode<=0xfdef) ){
/* U+FDD0..U+FDEF are noncharacters. */
return 0;
}
}else if( (unicode>=0xD800) && (unicode<=0xDFFF) ){
/* U+D800..U+DFFF are for surrogate pairs. */
return 0;
}
}
do{
if( (z[1]&0xc0)!=0x80 ){
/* Invalid continuation byte (multi-byte UTF-8) */
return 0;
}
/* The hi-bits of c are used to keep track of the number of expected
* continuation-bytes, so we don't need a separate counter. */
c<<=1; ++z;
}while( c>=0xc0 );
}else if( c=='\\' ){
return 0;
}
if( c=='/' ){
if( z[i+1]=='/' ) return 0;
if( z[i+1]=='.' ){
|
|
|
|
|
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
|
if( c&0x10 ){
/* Unicode characters > U+FFFF are not supported.
* Windows XP and earlier cannot handle them.
*/
return 0;
}
/* This is a 3-byte UTF-8 character */
unicode = ((c&0x0f)<<12) + ((z[i+1]&0x3f)<<6) + (z[i+2]&0x3f);
if( unicode <= 0x07ff ){
/* overlong form */
return 0;
}else if( unicode>=0xe000 ){
/* U+E000..U+FFFF */
if( (unicode<=0xf8ff) || (unicode>=0xfffe) ){
/* U+E000..U+F8FF are for private use.
* U+FFFE..U+FFFF are noncharacters. */
return 0;
} else if( (unicode>=0xfdd0) && (unicode<=0xfdef) ){
/* U+FDD0..U+FDEF are noncharacters. */
return 0;
}
}else if( (unicode>=0xD800) && (unicode<=0xDFFF) ){
/* U+D800..U+DFFF are for surrogate pairs. */
return 0;
}
}
do{
if( (z[i+1]&0xc0)!=0x80 ){
/* Invalid continuation byte (multi-byte UTF-8) */
return 0;
}
/* The hi-bits of c are used to keep track of the number of expected
* continuation-bytes, so we don't need a separate counter. */
c<<=1; ++i;
}while( c>=0xc0 );
}else if( c=='\\' ){
return 0;
}
if( c=='/' ){
if( z[i+1]=='/' ) return 0;
if( z[i+1]=='.' ){
|