| From: John Gruber | Date Sent: 2004-09-02 09:37:02 |
| Subject: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
Bryan Harris <lists@[Protected]> wrote on 09/01/04 at 9:49pm:
> Actually, I didn't know everything it did, I just knew that after running it
> I could feel confident that it was reduced back to base characters that
> should display cleanly on any platform.
>
> So I ran a test to figure it out, and for those who didn't know here's the
> basic result (only checking up to character number 255, I don't know what
> happens above that):
Here's a Perl filter implementation that emulates the old Convert to
ASCII plug-in. Save it as "Convert to ASCII" (or whatever name you
want) in your Unix Filters folder:
~/Library/Application Support/BBEdit/Unix Support/Unix Filters/
The old Convert to ASCII plug-in dialog allowed you to configure the
output for: 'ß', '«»', and '•'. I've commented out alternate
substitutions for this characters.
Hope this helps,
-J.G.
* * *
#!/usr/bin/perl
#
# Perl filter implementation of BBEdit's old Convert to ASCII plug-in.
#
use strict;
use warnings;
while (<>) {
print ConvertToAscii($_);
}
sub ConvertToAscii {
local $_ = shift;
#
# These first three were configurable in the old
# Convert to ASCII dialog box:
#
s{ß}{B}g;
# s{ß}{ss}g;
s{•}{*}g;
# s{•}{o}g;
s{«}{"}g;
s{»}{"}g;
# s{«}{<<}g;
# s{»}{>>}g;
s{Ä}{Ae}g;
s{Å}{A}g;
s{Ç}{C}g;
s{É}{E}g;
s{Ñ}{N}g;
s{Ö}{Oe}g;
s{Ü}{Ue}g;
s{á}{a}g;
s{à}{a}g;
s{â}{a}g;
s{ä}{ae}g;
s{ã}{a}g;
s{å}{a}g;
s{ç}{c}g;
s{é}{e}g;
s{è}{e}g;
s{ê}{e}g;
s{ë}{e}g;
s{í}{i}g;
s{ì}{i}g;
s{î}{i}g;
s{ï}{i}g;
s{ñ}{n}g;
s{ó}{o}g;
s{ò}{o}g;
s{ô}{o}g;
s{ö}{oe}g;
s{õ}{o}g;
s{ú}{u}g;
s{ù}{u}g;
s{û}{u}g;
s{ü}{ue}g;
s{†}{*}g;
s{°}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
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: Google Kreme | Date Sent: 2004-09-02 11:04:35 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
On Thu, 2 Sep 2004 12:37:02 -0400, John Gruber <jg@[Protected]> wrote:
> Here's a Perl filter implementation that emulates the old Convert to
> ASCII plug-in. Save it as "Convert to ASCII" (or whatever name you
> want) in your Unix Filters folder:
Works for me. All Hail the return of "Convert To Ascii"!
--
::::== <http://2blog.kreme.com> ==::::
:: Don't get saucy with me, Bernaise ::
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: Tim Gray | Date Sent: 2004-09-02 18:51:02 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
On 9/2/04 at 12:37 PM, John Gruber <jg@[Protected]> wrote:
>Here's a Perl filter implementation that emulates the old Convert to
>ASCII plug-in. Save it as "Convert to ASCII" (or whatever name you
>want) in your Unix Filters folder:
Thanks a bunch for your perl filter, but can anyone help me with the
behavior I get when I run it? A couple examples:
‰ -> ,Ae()()
© -> -(c)
¥ -> -*
When I run it from the command line, I get the same conversions. If it
makes any difference, I have perl v5.8.1-RC3 (I've never installed this,
so I have whatever has been brought up with OS X).
Thanks!
Tim
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: Bryan Harris | Date Sent: 2004-09-02 23:34:28 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
> Bryan Harris <lists@[Protected]> wrote on 09/01/04 at 9:49pm:
>
>> Actually, I didn't know everything it did, I just knew that after running it
>> I could feel confident that it was reduced back to base characters that
>> should display cleanly on any platform.
>>
>> So I ran a test to figure it out, and for those who didn't know here's the
>> basic result (only checking up to character number 255, I don't know what
>> happens above that):
>
> Here's a Perl filter implementation that emulates the old Convert to
> ASCII plug-in. Save it as "Convert to ASCII" (or whatever name you
> want) in your Unix Filters folder:
>
> ~/Library/Application Support/BBEdit/Unix Support/Unix Filters/
>
> The old Convert to ASCII plug-in dialog allowed you to configure the
> output for: '', '', and ''. I've commented out alternate
> substitutions for this characters.
>
> Hope this helps,
BB folks, please don't take John's script as a reason not to put that
feature back in... He did a great job, but there's nothing like the real
deal.
- B
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: Patrick Woolsey | Date Sent: 2004-09-03 05:04:11 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
Bryan Harris <lists@[Protected]> sez:
[...]
>BB folks, please don't take John's script as a reason not to put that
>feature back in... He did a great job, but there's nothing like the real
>deal.
>
We most likely will return Convert to ASCII to the lineup; usual
disclaimers apply. :)
Regards,
Patrick Woolsey / Director of Technical Services
==
Bare Bones Software, Inc. <http://www.barebones.com>
P.O. Box 1048, Bedford, MA 01730-1048
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: John Gruber | Date Sent: 2004-09-03 07:44:36 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
Tim Gray <tgray@[Protected]> wrote on 09/02/04 at 9:51pm:
> Thanks a bunch for your perl filter, but can anyone help me with the
> behavior I get when I run it? A couple examples:
>
> ‰ -> ,Ae()()
> © -> -(c)
> ¥ -> -*
These work here. (I tested the script against the output of the
Convert to ASCII plug-in in Mailsmith.)
Perhaps this is a text encoding problem. I have the filter saved as
UTF-8/no BOM; and in the Unix Scripting prefs panel, I have "Use
UTF-8 for Unix Script I/O" turned on.
-J.G.
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: Rob Stevenson | Date Sent: 2004-09-03 11:06:48 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
Hi Patrick,
On Sep 3, 2004, at 10:32 AM, Patrick Woolsey wrote:
> We most likely will return Convert to ASCII to the lineup; usual
> disclaimers apply. :)
Since you're in a contrite mood (well, I can imagine it at least)
please also rethink that saved-state-disappears-after-14-days thing
people have mentioned here. Until that's fixed (put into a Pref I
suppose) I'm up close and personal with 7.1.4. I _like_ where I put my
windows, even if I last opened them 6 months ago.
And while I have your ear, thanks for the drawer - I can see myself
getting to like that, soon, I hope.
Rob
Rob Stevenson
The Donut Machine
www.donutmachine.ca
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: Rich Siegel | Date Sent: 2004-09-03 11:31:21 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
On 9/3/04 at 3:06 PM, Rob Stevenson <rstevenson@[Protected]> wrote:
> please also rethink that saved-state-disappears-after-14-days thing
> people have mentioned here. Until that's fixed (put into a Pref I
> suppose) I'm up close and personal with 7.1.4. I _like_ where I put my
> windows, even if I last opened them 6 months ago.
Well, since it's impossible for you to have been using the software for
either 14 days -or- six months at this point :-), may I recommend that
you give it a try first?
R.
--
Rich Siegel Bare Bones Software, Inc.
<siegel@[Protected]> <http://www.barebones.com/>
Someday I'll look back on all this and laugh... until they sedate me.
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: Tim Gray | Date Sent: 2004-09-03 12:16:20 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
On Friday, September 3, 2004, John Gruber <jg@[Protected]> said:
>Perhaps this is a text encoding problem. I have the filter saved as
>UTF-8/no BOM; and in the Unix Scripting prefs panel, I have "Use
>UTF-8 for Unix Script I/O" turned on.
That was it! Thanks.
Tim
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: Rob Stevenson | Date Sent: 2004-09-03 12:38:53 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
You mean people on this list can say things that AREN'T TRUE? Say it
isn't so!
Rob
On Sep 3, 2004, at 4:02 PM, Rich Siegel wrote:
> On 9/3/04 at 3:06 PM, Rob Stevenson <rstevenson@[Protected]> wrote:
>
>> please also rethink that saved-state-disappears-after-14-days thing
>> people have mentioned here. Until that's fixed (put into a Pref I
>> suppose) I'm up close and personal with 7.1.4. I _like_ where I put my
>> windows, even if I last opened them 6 months ago.
>
> Well, since it's impossible for you to have been using the software for
> either 14 days -or- six months at this point :-), may I recommend that
> you give it a try first?
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: Kenneth Kirksey | Date Sent: 2004-09-03 13:46:03 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
On 09/02/04 at 12:37 PM -0400, John Gruber <jg@[Protected]> wrote:
> Here's a Perl filter implementation that emulates the old Convert to
> ASCII plug-in.
Thank you, thank you, thank you! I'm having a little problem with the script, though, which I think has to do with the fact the BBEdit is treating the text I paste in as Unicode instead of ASCII.
I copied the following test from a web site:
d—it
that second byte should be an en- or em- dash. When I hex dump that window in BBEdit, I see:
0000: 00 64 20 14 00 69 00 74 ¿d ¿¿i¿t
Two bytes per character? Not ASCII. When I run your script, I get:
d,Aeiit
If I copy the same text to a window in Mailsmith and run "Convert to ASCII", I get:
d--it.
So I guess the question is, how do I get BBEdit to treat the text I paste in as ASCII instead of Unicode. Thanks!
Ken
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: John Gruber | Date Sent: 2004-09-03 17:47:46 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
Kenneth Kirksey <kk_lists@[Protected]> wrote on 09/03/04 at 4:46pm:
> Thank you, thank you, thank you! I'm having a little problem with
> the script, though, which I think has to do with the fact the
> BBEdit is treating the text I paste in as Unicode instead of ASCII.
You're confused about what ASCII is. ASCII is a 7-bit text
encoding format -- it only contains normal characters like a-z and
A-Z, and standard U.S. punctuation characters.
Any text document containing other characters is in some sort of
non-ASCII text encoding format. On the Mac, this is traditionally
Mac Roman. On Windows, it's often Windows Latin 1. Unicode encodings
such as UTF-8 and UTF-16 are richer (thousands of characters,
instead of only 256), cross-platform, and more fragrant.
I think your problem with this text filter is similar to the one
reported yesterday. I suggested:
> Perhaps this is a text encoding problem. I have the filter saved as
> UTF-8/no BOM; and in the Unix Scripting prefs panel, I have "Use
> UTF-8 for Unix Script I/O" turned on.
In other words, open the "Convert to ASCII" filter file in BBEdit,
make sure it's saved as UTF-8/no BOM, and then turn on the
aforementioned preference checkbox.
See if that works for you.
Regards,
-J.G.
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>
| From: Kenneth Kirksey | Date Sent: 2004-09-03 18:16:49 |
| Subject: Re: Convert to ASCII as a Perl filter (was Re: Three cheers!) | To: BBEdit Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
On 09/03/04 at 8:47 PM -0400, John Gruber <gruber@[Protected]> wrote:
> > Thank you, thank you, thank you! I'm having a little problem with
> > the script, though, which I think has to do with the fact the
> > BBEdit is treating the text I paste in as Unicode instead of ASCII.
>
> You're confused about what ASCII is. ASCII is a 7-bit text
> encoding format -- it only contains normal characters like a-z and
> A-Z, and standard U.S. punctuation characters.
>
> Any text document containing other characters is in some sort of
> non-ASCII text encoding format.
No, I'm pretty sure I know what ASCII is, having written an EBCDIC to ASCII translator for an IBM S/36 a number of years ago. :-) Not to pick nits, but this statement is not quite true. The first 32 characters in the ASCII character set are non-printing control characters.
> In other words, open the "Convert to ASCII" filter file in BBEdit,
> make sure it's saved as UTF-8/no BOM, and then turn on the
> aforementioned preference checkbox.
>
> See if that works for you.
It did indeed. Thanks!
Ken
--
----------------------------------------------------------
Please send bug reports to <support@[Protected]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-off@[Protected]>