Skip to content

Instantly share code, notes, and snippets.

@njm2112
Forked from benrothe/StraightenQuotes.sh
Created December 24, 2016 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njm2112/6772a8ebe5487557660a63db1d0681d9 to your computer and use it in GitHub Desktop.
Save njm2112/6772a8ebe5487557660a63db1d0681d9 to your computer and use it in GitHub Desktop.
A TextExpander snippet to convert clipboard contents: “Curly” quotes to "straight", em-dashes to double-hyphens and ellipses to three periods.
#!/usr/bin/env php
<?php
$str = `pbpaste`;
$find = array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6");
$replace = array("'", "'", '"', '"', '-', '--', '...');
echo str_replace($find, $replace, $str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment