It means there is a glitch in the matrix - agents are coming!
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
Jump to
Showing posts with label utf8. Show all posts
Showing posts with label utf8. Show all posts
Find dodgy characters in a file
This will print any characters with values higher than 127, i.e. non-ascii characters that might look like ascii, but really be breaking your processor.
perl -lne'while (my ($c) = $_ =~ m{^(.)}) { print "$c = ".ord($c) if ord($c) > 127; $_ =~ s/^.// }' file_to_check.something
A quick, manual way to confirm some characters really are what you think they are:
cat file_to_check.something | od -bc
perl -lne'while (my ($c) = $_ =~ m{^(.)}) { print "$c = ".ord($c) if ord($c) > 127; $_ =~ s/^.// }' file_to_check.something
A quick, manual way to confirm some characters really are what you think they are:
cat file_to_check.something | od -bc
Labels:
ascii,
characters,
dodgy,
encoding,
non-printable,
one-liner,
perl,
utf8
Convert a string to UTF8
If the string is in iso-8859-1 encoding:
my $string_iso_8859_1 = decode("iso-8859-1", $string);
my $string_utf8 = encode("utf8", $string_iso_8859_1);
my $string_iso_8859_1 = decode("iso-8859-1", $string);
my $string_utf8 = encode("utf8", $string_iso_8859_1);
Subscribe to:
Posts (Atom)