Changeset 982 for trunk/cgi-bin/ljlib.pl

Show
Ignore:
Timestamp:
04/08/02 18:08:19 (11 years ago)
Author:
bradfitz
Message:

allow alternative utf-8 checker, or fall back to slow perl one.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/ljlib.pl

    r965 r982  
    53185318    my $text = shift; 
    53195319 
    5320     $text =~ m/^([\x00-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf])*(.*)/; 
    5321  
    5322     return 1 unless $2; 
    5323     return 0; 
     5320    if (LJ::are_hooks("is_utf8")) { 
     5321        my @r = LJ::run_hooks("is_utf8", $text); 
     5322        return 0 if grep { ! $_->[0] } @r; 
     5323        return 1; 
     5324    } 
     5325    else { 
     5326        $text =~ m/^([\x00-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf])*(.*)/; 
     5327 
     5328        return 1 unless $2; 
     5329        return 0; 
     5330    } 
    53245331} 
    53255332