Help for this page

Select Code to Download


  1. or download this
    # my @input = ( 0xC1, 0xB3, 0xE0, 0x81, ... );
    my @input = do { local $/; unpack "C*", pack "H*", <> =~ s/\s//gr };
    
  2. or download this
    # my $input = "\xC1\xB3\xE0\x81...";
    my $input = do { local $/; pack "H*", <> =~ s/\s//gr };
    
  3. or download this
    (?: [\x00-\x7F]
    |   [\xC0-\xDF][\x80-\xBF]
    |   [\xE0-\xEF][\x80-\xBF]{2}
    |   ...
    )
    
  4. or download this
    my @bytes = unpack 'C*', $encoded_value;
    
    ...
    elsif (@bytes == 2) { push @output, (( $bytes[0] & 0x1F ) << 6 ) | ( $
    +bytes[0] & 0x3F ); }
    elsif (@bytes == 3) { push @output, (( $bytes[0] & 0x0F ) << 12 ) | ((
    + $bytes[0] & 0x3F ) << 6 ) | ( $bytes[0] & 0x3F ); }
    ...
    
  5. or download this
    say join " ", map sprintf("%X", $_), @output;
    
  6. or download this
    # Separated by "." instead of spaces.
    say sprintf "%vX", pack "W*", @output;