A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label characters. Show all posts
Showing posts with label characters. Show all posts

What "Wide character in print" means in Perl (hint: UTF8)

 It means there is a glitch in the matrix - agents are coming!

(further reading)

Type GBP symbol without numeric keypad

Full size keyboard numpad method

If you have a numeric keypad to the right of you keyboard, you can type Alt+0163 to get a UK pound sterling symbol on a US-keyboard.

Modern laptop numpad method

Some laptops use a Fn (function) key and overlay the numpad on the main keyboard - so on a Dell Latitude I can hold Alt+Fn and type MJOL (which corresponds to 0163) to get a £ symbol.

...but some modern laptops don't have a numeric keypad at all. For those situations, see below.

Keyboard language switch

Install a UK keyboard alongside the US keyboard in control panel, and then type Win+Space to switch between them. Probably Windows 10 only.

Shift-3 usually types a # (hashtag) when set to US keyboard, and a £ (pound sterling) when set to UK keyboard.

Windows 10 character map (May 2019 update)

Type Win+. (dot) and you'll get a character map with all the symbols you'll ever need! 😊

It even remembers the ones you've used recently for quick access. (❁´◡`❁)

For faster keyboard navigation you can press [Tab] to cycle through the controls and [Enter] to select.

Old Windows method

Open the character map application from the start menu. You can search for it in the latest Windows, or it may be hidden in the Accessories folder for older versions.


See hidden characters in a string

perl -e '$HOSTNAME = `hostname -s`; print $HOSTNAME;' | od -c

Delete a file starting with a dash

You accidentally created a file called "-.log"

To delete it, instead of
rm -.log
try
rm ./-.log

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

How to use single quotes in a Perl one-liner

perl -le'$q=chr(39); print "quote mark: $q" '
(linux)

Insert non-printable characters in vi

  • Ctrl-V, then Ctrl-[X]
Where [X] is A-F

Check for non-ascii characters

perl -lne'until (! $_) { s/^(.)//; $c = $1; print $_ if ord($c) > 127 }' file.html

Lowercasing in XSL

translate(field_to_change, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz').

Case sensitive MySQL column

Make a case sensitive varchar column:

CREATE TABLE `page_dm` (
`url` varchar(500) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html
http://dev.mysql.com/doc/refman/5.0/en/create-table.html

Toggle visibility of non-printable characters in Mac Word

Preferences | View | Nonprinting characters -> tick boxes