grep pattern decode quoted-printable

208 views
Skip to first unread message

irep

unread,
Aug 9, 2016, 10:17:25 PM8/9/16
to BBEdit Talk
Hello.

How can I decode quoted-printable paragraphs or the whole text in say UTF8 with BBedit 11 or TextWrangler ? 
I am totally newbie with grep. I thought one could find a kind of "shared library" filled with grep patterns to do this :)
I have found tools online but its not so handy. 

Thank you for your help.

Rich Siegel

unread,
Aug 9, 2016, 10:28:14 PM8/9/16
to bbe...@googlegroups.com
On Tuesday, August 9, 2016, irep <peri.van...@gmail.com> wrote:

>How can I decode quoted-printable paragraphs or the whole text
>in say UTF8 with BBedit 11 or TextWrangler ?

You can do this in Python with the "quopri" package:
<https://docs.python.org/2/library/quopri.html>. A simple Python
text filter placed in your Application Support/BBEdit/Text
Filters/ folder will allow you to apply this to the selected text.

(I suspect that Perl and Ruby also have library functions for
doing this.)

Enjoy,

R.
--
Rich Siegel Bare Bones Software, Inc.
<sie...@barebones.com> <http://www.barebones.com/>

Someday I'll look back on all this and laugh... until they
sedate me.

Charlie Garrison

unread,
Aug 9, 2016, 11:37:25 PM8/9/16
to BBEdit Talk

Paste the following into a file, and save it in the BBEdit “Text Filters” directory.

#!/usr/bin/perl -w

use strict;

use MIME::Decoder;

my $decoder = new MIME::Decoder 'quoted-printable' or die "unsupported";
$decoder->decode(\*STDIN, \*STDOUT);

1;

If MIME::Decoder isn’t already installed; try to install with:

sudo cpan MIME::Decoder

Charlie
--

Charlie Garrison garr...@zeta.org.au
github.com/cngarrison metacpan.org/author/CNG

O< ascii ribbon campaign - stop html mail
Conundrum

irep

unread,
Aug 10, 2016, 9:15:45 AM8/10/16
to BBEdit Talk
Thank you very much Rich and Charlie

@Rich

I did what you wrote and placed it as a .py file in Applications support>BBedit>Text Filters.
In BBedit, I can see the new menu item and use it but the quoted-printable characters get coded differently but still not showing accents (dyacritics signs)
For example: apr=C3=A8s becomes :
apr=3DC3=3DA8s
instead of: après

So I tried Charly's advice :

Le mercredi 10 août 2016 05:37:25 UTC+2, Charlie Garrison a écrit :

Paste the following into a file, and save it in the BBEdit “Text Filters” directory.

#!/usr/bin/perl -w

use strict;

use MIME::Decoder;

my $decoder = new MIME::Decoder 'quoted-printable' or die "unsupported";
$decoder->decode(\*STDIN, \*STDOUT);

1;

I did it and placed it as a .txt file in Applications support>BBedit>Text Filters.
In BBedit, I can see the new menu item and use it but the quoted-printable characters get coded differently but still not showing accents (dyacritics signs)
For example: apr=C3=A8s becomes :
après
instead of: après

But after some tries it worked fine !

Before it worked fine, I did the following, but this shouldn't be a big deal :

If MIME::Decoder isn’t already installed; try to install with:

sudo cpan MIME::Decoder

 

I did this in Terminal and got a huge log with a lot of external connections (to mirrors):

 
CPAN is the world-wide archive of perl resources. It consists of about
300 sites that all replicate the same contents around the globe. Many
countries have at least one CPAN site already. The resources found on
CPAN are easily accessible with the CPAN.pm module. If you want to use
CPAN.pm, lots of things have to be configured. Fortunately, most of
them can be determined automatically. If you prefer the automatic
configuration, answer 'yes' below.

If you prefer to enter a dialog instead, you can answer 'no' to this
question and I'll let you configure in small steps one thing after the
other. (Note: you can revisit this dialog anytime later by typing 'o
conf init' at the cpan prompt.)

Would you like me to configure as much as possible automatically? [yes] yes


Autoconfigured everything but 'urllist'.

Now you need to choose your CPAN mirror sites.  You can let me
pick mirrors for you, you can select them from a list or you
can enter them by hand.

Would you like me to automatically choose the best CPAN mirror
sites for you? (This means connecting to the Internet and could
take a couple minutes) [yes] yes

Trying to fetch a mirror list from the Internet
  LWP not available
  LWP not available
Fetching with Net::FTP:

Searching for the best CPAN mirrors (please be patient) ............................................................................................... done!

New urllist

Autoconfiguration complete.

commit: wrote '/opt/local/lib/perl5/5.12.4/CPAN/Config.pm'
  LWP not available
Fetching with Net::FTP:
Going to read '/Users/myname/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
  LWP not available
Fetching with Net::FTP:
Going to read '/Users/myname/.cpan/sources/modules/02packages.details.txt.gz'
  Database was generated on Wed, 10 Aug 2016 06:29:02 GMT
  HTTP::Date not available
.............
  New CPAN.pm version (v2.14) available.
  [Currently running version is v1.9456]
  You might want to try
    install CPAN
    reload cpan
  to both upgrade CPAN.pm and run the new version without leaving
  the current session.


...............................................................DONE
  LWP not available
Fetching with Net::FTP:
Going to read '/Users/myname/.cpan/sources/modules/03modlist.data.gz'
DONE
Going to write /Users/myname/.cpan/Metadata
Running install for module 'MIME::Decoder'
Running make for D/DS/DSKOLL/MIME-tools-5.507.tar.gz
  LWP not available
Fetching with Net::FTP:
  LWP not available
Fetching with Net::FTP:
Checksum for /Users/myname/.cpan/sources/authors/id/D/DS/DSKOLL/MIME-tools-5.507.tar.gz ok
---- Unsatisfied dependencies detected during ----
----      DSKOLL/MIME-tools-5.507.tar.gz      ----
    ExtUtils::MakeMaker [build_requires]
Running make test
  Make had some problems, won't test
  Delayed until after prerequisites
Running make install
  Make had some problems, won't install
  Delayed until after prerequisites
Running install for module 'ExtUtils::MakeMaker'
Running make for B/BI/BINGOS/ExtUtils-MakeMaker-7.22.tar.gz
  LWP not available
Fetching with Net::FTP:
  LWP not available
Fetching with Net::FTP:
Checksum for /Users/myname/.cpan/sources/authors/id/B/BI/BINGOS/ExtUtils-MakeMaker-7.22.tar.gz ok

  CPAN.pm: Going to build B/BI/BINGOS/ExtUtils-MakeMaker-7.22.tar.gz

Using included version of CPAN::Meta (2.143240) because it is not already installed.
Using included version of CPAN::Meta::Requirements (2.131) because it is not already installed.
Using included version of CPAN::Meta::YAML (0.011) because it is not already installed.
Using included version of ExtUtils::Manifest (1.70) as it is newer than the installed version (1.57).
Using included version of JSON::PP (2.27203) because it is not already installed.
Using included version of Parse::CPAN::Meta (1.4414) as it is newer than the installed version (1.40).
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for ExtUtils::MakeMaker
Writing MYMETA.yml and MYMETA.json
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  BINGOS/ExtUtils-MakeMaker-7.22.tar.gz
  /usr/bin/make -- NOT OK
'YAML' not installed, will not store persistent state
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Running make for D/DS/DSKOLL/MIME-tools-5.507.tar.gz
Warning: Prerequisite 'ExtUtils::MakeMaker => 6.59' for 'DSKOLL/MIME-tools-5.507.tar.gz' failed when processing 'BINGOS/ExtUtils-MakeMaker-7.22.tar.gz' with 'make => NO'. Continuing, but chances to succeed are limited.

  CPAN.pm: Going to build D/DS/DSKOLL/MIME-tools-5.507.tar.gz

Checking if your kit is complete...
Looks good
Warning: prerequisite ExtUtils::MakeMaker 6.59 not found. We have 6.56.
Warning: prerequisite Mail::Field 1.05 not found.
Warning: prerequisite Mail::Header 1.01 not found.
Warning: prerequisite Mail::Internet 1.0203 not found.
Warning: prerequisite Test::Deep 0 not found.
Writing Makefile for MIME::Tools
Warning: Prerequisite 'ExtUtils::MakeMaker => 6.59' for 'DSKOLL/MIME-tools-5.507.tar.gz' failed when processing 'BINGOS/ExtUtils-MakeMaker-7.22.tar.gz' with 'make => NO'. Continuing, but chances to succeed are limited.
---- Unsatisfied dependencies detected during ----
----      DSKOLL/MIME-tools-5.507.tar.gz      ----
    Mail::Header [requires]
    Mail::Field [requires]
    Mail::Internet [requires]
    Test::Deep [requires]
Running make test
  Delayed until after prerequisites
Running make install
  Delayed until after prerequisites
Running install for module 'Mail::Header'
Running make for M/MA/MARKOV/MailTools-2.18.tar.gz
  LWP not available
Fetching with Net::FTP:
  LWP not available
Fetching with Net::FTP:
Checksum for /Users/myname/.cpan/sources/authors/id/M/MA/MARKOV/MailTools-2.18.tar.gz ok

  CPAN.pm: Going to build M/MA/MARKOV/MailTools-2.18.tar.gz

Checking if your kit is complete...
Looks good
Warning: prerequisite Date::Format 0 not found.
Warning: prerequisite Date::Parse 0 not found.
Writing Makefile for Mail
---- Unsatisfied dependencies detected during ----
----       MARKOV/MailTools-2.18.tar.gz       ----
    Date::Format [requires]
    Date::Parse [requires]
Running make test
  Delayed until after prerequisites
Running make install
  Delayed until after prerequisites
Running install for module 'Date::Format'
Running make for G/GB/GBARR/TimeDate-2.30.tar.gz
  LWP not available
Fetching with Net::FTP:
  LWP not available
Fetching with Net::FTP:
Checksum for /Users/myname/.cpan/sources/authors/id/G/GB/GBARR/TimeDate-2.30.tar.gz ok

  CPAN.pm: Going to build G/GB/GBARR/TimeDate-2.30.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Date::Parse
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  GBARR/TimeDate-2.30.tar.gz
  /usr/bin/make -- NOT OK
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Running install for module 'Date::Parse'
Running make for G/GB/GBARR/TimeDate-2.30.tar.gz
  Has already been unwrapped into directory /Users/myname/.cpan/build/TimeDate-2.30-0JYBnW
Could not make: Unknown error
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Running make for M/MA/MARKOV/MailTools-2.18.tar.gz
  Has already been unwrapped into directory /Users/myname/.cpan/build/MailTools-2.18-fIo0Nv

  CPAN.pm: Going to build M/MA/MARKOV/MailTools-2.18.tar.gz

Warning: Prerequisite 'Date::Format => 0' for 'MARKOV/MailTools-2.18.tar.gz' failed when processing 'GBARR/TimeDate-2.30.tar.gz' with 'make => NO'. Continuing, but chances to succeed are limited.
Warning: Prerequisite 'Date::Parse => 0' for 'MARKOV/MailTools-2.18.tar.gz' failed when processing 'GBARR/TimeDate-2.30.tar.gz' with 'make => NO'. Continuing, but chances to succeed are limited.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  MARKOV/MailTools-2.18.tar.gz
  /usr/bin/make -- NOT OK
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Running install for module 'Mail::Field'
Running make for M/MA/MARKOV/MailTools-2.18.tar.gz
  Has already been unwrapped into directory /Users/myname/.cpan/build/MailTools-2.18-fIo0Nv
Could not make: Unknown error
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Running install for module 'Mail::Internet'
Running make for M/MA/MARKOV/MailTools-2.18.tar.gz
  Has already been unwrapped into directory /Users/myname/.cpan/build/MailTools-2.18-fIo0Nv
Could not make: Unknown error
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Running install for module 'Test::Deep'
Running make for R/RJ/RJBS/Test-Deep-1.120.tar.gz
  LWP not available
Fetching with Net::FTP:
  LWP not available
Fetching with Net::FTP:
Checksum for /Users/myname/.cpan/sources/authors/id/R/RJ/RJBS/Test-Deep-1.120.tar.gz ok

  CPAN.pm: Going to build R/RJ/RJBS/Test-Deep-1.120.tar.gz

Checking if your kit is complete...
Looks good
Warning: prerequisite Test::Tester 0.04 not found.
Writing Makefile for Test::Deep
---- Unsatisfied dependencies detected during ----
----        RJBS/Test-Deep-1.120.tar.gz       ----
    Test::Tester [requires]
Running make test
  Delayed until after prerequisites
Running make install
  Delayed until after prerequisites
Running install for module 'Test::Tester'
Running make for E/EX/EXODIST/Test-Simple-1.302049.tar.gz
  LWP not available
Fetching with Net::FTP:
  LWP not available
Fetching with Net::FTP:
Checksum for /Users/myname/.cpan/sources/authors/id/E/EX/EXODIST/Test-Simple-1.302049.tar.gz ok

  CPAN.pm: Going to build E/EX/EXODIST/Test-Simple-1.302049.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Test::Simple
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  EXODIST/Test-Simple-1.302049.tar.gz
  /usr/bin/make -- NOT OK
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Running make for R/RJ/RJBS/Test-Deep-1.120.tar.gz
  Has already been unwrapped into directory /Users/myname/.cpan/build/Test-Deep-1.120-XJ3QTX

  CPAN.pm: Going to build R/RJ/RJBS/Test-Deep-1.120.tar.gz

Warning: Prerequisite 'Test::Tester => 0.04' for 'RJBS/Test-Deep-1.120.tar.gz' failed when processing 'EXODIST/Test-Simple-1.302049.tar.gz' with 'make => NO'. Continuing, but chances to succeed are limited.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  RJBS/Test-Deep-1.120.tar.gz
  /usr/bin/make -- NOT OK
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Running make for D/DS/DSKOLL/MIME-tools-5.507.tar.gz
  Has already been unwrapped into directory /Users/myname/.cpan/build/MIME-tools-5.507-h8FWlA

  CPAN.pm: Going to build D/DS/DSKOLL/MIME-tools-5.507.tar.gz

Warning: Prerequisite 'Mail::Header => 1.01' for 'DSKOLL/MIME-tools-5.507.tar.gz' failed when processing 'MARKOV/MailTools-2.18.tar.gz' with 'make => NO'. Continuing, but chances to succeed are limited.
Warning: Prerequisite 'ExtUtils::MakeMaker => 6.59' for 'DSKOLL/MIME-tools-5.507.tar.gz' failed when processing 'BINGOS/ExtUtils-MakeMaker-7.22.tar.gz' with 'make => NO'. Continuing, but chances to succeed are limited.
Warning: Prerequisite 'Mail::Field => 1.05' for 'DSKOLL/MIME-tools-5.507.tar.gz' failed when processing 'MARKOV/MailTools-2.18.tar.gz' with 'make => NO'. Continuing, but chances to succeed are limited.
Warning: Prerequisite 'Mail::Internet => 1.0203' for 'DSKOLL/MIME-tools-5.507.tar.gz' failed when processing 'MARKOV/MailTools-2.18.tar.gz' with 'make => NO'. Continuing, but chances to succeed are limited.
Warning: Prerequisite 'Test::Deep => 0' for 'DSKOLL/MIME-tools-5.507.tar.gz' failed when processing 'RJBS/Test-Deep-1.120.tar.gz' with 'make => NO'. Continuing, but chances to succeed are limited.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  DSKOLL/MIME-tools-5.507.tar.gz
  /usr/bin/make -- NOT OK
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
iMac-de-myname:~ myname$ 


So I tried Installing LWP from the CPAN Shell (Via Terminal) but got:
iMac-de-myname:~ myname$ perl -MCPAN -eshell
Terminal does not support AddHistory.


Your configuration suggests that CPAN.pm should use a working
directory of
    /Users/myname/.cpan
Unfortunately we could not create the lock file
    /Users/myname/.cpan/.lock
due to permission problems.

Please make sure that the configuration variable
    $CPAN::Config->{cpan_home}
points to a directory where you can write a .lock file. You can set
this variable in either a CPAN/MyConfig.pm or a CPAN/Config.pm in your
@INC path;
You don't seem to have a user configuration (MyConfig.pm) yet.
Do you want to create a user configuration now? (Y/n) [yes] yes
mkdir /Users/myname/.cpan/CPAN: Permission denied at /opt/local/lib/perl5/5.12.4/CPAN/Shell.pm line 663
iMac-de-myname:~ myname$ 



 

Charlie Garrison

unread,
Aug 10, 2016, 7:55:21 PM8/10/16
to BBEdit Talk

On 10 Aug 2016, at 19:27, irep wrote:

I did this in Terminal and got a huge log with a lot of external connections (to mirrors):

I don’t install stuff into the system perl, so not sure how to help with those errors. I use perlbrew for a custom Perl installation for each project, and installing modules is trivial.

Having a quick read of the log you showed, my first guess is you don’t have Dev Tools (Xcode) installed. You need those in order to install Perl modules.

This is the error that actually stopped things:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Ronald J Kimball

unread,
Aug 12, 2016, 5:27:51 PM8/12/16
to bbe...@googlegroups.com
On Wed, Aug 10, 2016 at 02:27:26AM -0700, irep wrote:
> Thank you very much Rich and Charlie
>
> @Rich
>
> I did what you wrote and placed it as a .py file in Applications
> support>BBedit>Text Filters.
> In BBedit, I can see the new menu item and use it but the quoted-printable
> characters get coded differently but still not showing accents (dyacritics
> signs)
> For example: *apr=C3=A8s* becomes :
> apr=3DC3=3DA8s
> instead of: *après*

It looks like you used encode instead of decode.

Ronald

irep

unread,
Aug 13, 2016, 9:56:27 AM8/13/16
to BBEdit Talk
Le vendredi 12 août 2016 23:27:51 UTC+2, Ronald J Kimball a écrit :
It looks like you used encode instead of decode.
Ronald
Thank you Ronald. I need to erase a part of the script to solely decode? :D Silly me…  
Reply all
Reply to author
Forward
0 new messages