Help for this page

Select Code to Download


  1. or download this
    sub is_utf8 {
        utf8::upgrade( $_[0] );
        return 1;
    }
    
  2. or download this
    sub is_utf8 {
       my $s = "\x80" . $_[0];
       my $internal = unpack "p", pack "p", $s;
       return $s ne $internal;
    }
    
  3. or download this
    utf8::downgrade( my $empty_dn = ''          );  # 0
    utf8::upgrade(   my $empty_up = ''          );  # 1
    ...
    ) {
       print is_utf8($_)?1:0, "\n";
    }