Help for this page

Select Code to Download


  1. or download this
    $ perl -e 'print substr("a\x{2322}bcd", 0, 3), "\n";' | hexdump
    00000000  61 e2 8c a2 62 0a
    
  2. or download this
    $ perl -e 'print "a\x{2322}bcd\n"' > uni-file
    $ perl -ne 'print substr($_,0,3), "\n"' uni-file | hexdump
    00000000  61 e2 8c 0a
    
  3. or download this
    $ perl -ne 'utf8::upgrade($_);
    > print substr($_,0,3), "\n"' uni-file |
    > hexdump
    00000000  61 e2 8c 0a
    
  4. or download this
    $ perl -ne 'BEGIN{binmode(STDIN,":utf8");
    > print substr($_,0,3), "\n"' uni-file |
    > hexdump
    00000000  61 e2 8c a2 62 0a
    
  5. or download this
    $io->open($in_file, "<:raw:encoding(cp1252)")  ||  die(...);
    
  6. or download this
    while (!$io->eof) {
       $cols = $csvin->getline($io);
    ...
       $str = $col[0];
       print substr($str,0,3), "\n";   # XXX cuts through utf8 multibyte!
    }