Help for this page

Select Code to Download


  1. or download this
    $STRING =~ tr/\x00-\xFF//c   # Can be used as a boolean.
    
  2. or download this
    sub isASCII { !!( $_[0] =~ tr/\x00-\x7F//c ) }
    
  3. or download this
    my $ascii = encode( "ASCII", "\N{LATIN SMALL LETTER A}" );
    isASCII( $ascii )         # true (OK. true positive)
    ...
    my $temperature = 18;
    my $data_packet = pack( 's>', $temperature );
    isASCII( $data_packet )   # true (Error. false positive)