Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Searching for "fraction slash"

8 views
Skip to first unread message

Jolly Roger

unread,
Mar 20, 2015, 9:48:43 AM3/20/15
to
On 2015-03-20, isw <i...@witzend.com> wrote:

[Followups set to alt.comp.lang.applescript]

> I opened one of the recipes with a hex editor, and found that the
> location of the slash contains "\u8260 ". A search revealed that is
> "&frasl" in HTML, which is evidently a "fraction slash". The Mac's
> Character Viewer thinks that "fraction slash" is U+0066, for what that
> is worth.

8260 decimal is 2044 hexadecimal. In AppleScript, you can use the «data
utxt» formatter to work with Unicode characters. To get the fraction
slash character, you can use:

«data utxt2044» as Unicode text

> So all I want to do is find the thing so it can be replaced by a
> "regular" slash, but I need to know what to tell the AppleScript to look
> for, and I don't know how to do that.

This seems to work for me:

-- begin script
property bunchOfText : "this ⁄ is a test
of the emergency ⁄ broadcast system
please stay ⁄ calm
and bring ⁄ your towel"

property searchCharacter : «data utxt2044» as Unicode text

set newText to my SearchReplace(bunchOfText, searchCharacter, "/")

return my SearchReplace(newText, searchCharacter, "***")

on SearchReplace(sourceStr, searchString, replaceString)
-- replace <searchString> with <replaceString> in <sourceStr>
set searchStr to (searchString as text)
set replaceStr to (replaceString as text)
set sourceStr to (sourceStr as text)
set saveDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to (searchString)
set theList to (every text item of sourceStr)
set AppleScript's text item delimiters to (replaceString)
set theString to theList as string
set AppleScript's text item delimiters to saveDelims
return theString
end SearchReplace
-- end script

The "bunchOfText" property is a string with the Unicode 2044 characters
in it (added directly from the keyboard by typing Option-Shift-1. I used
the «data utxt» formatter to set the "searchCharacter" property to the
single Unicode 2044 character so I can search for it. I typed the « and
» characters on the keyboard with Option-\ and Option-Shift-\,
respectively. The SearchReplace handler uses an AppleScript text item
delimiter trick to locate the substring and replace it.

--
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR

isw

unread,
Mar 20, 2015, 6:08:38 PM3/20/15
to
In article <cn2mpp...@mid.individual.net>,
Jolly Roger <jolly...@pobox.com> wrote:

> On 2015-03-20, isw <i...@witzend.com> wrote:
>
> [Followups set to alt.comp.lang.applescript]

I thought about that, but decided that the problem concerning the
"fraction slash" was more of a global issue rather than something that
just concerned AppleScript, since even TextEdit had problems with it
(and see the last two paragraphs).

> TextEdit displays the fractions as overlapping, but it is not possible
> to select only the slash -- if you put the cursor over the slash of
> "1/2" and move it one way you select the "1", and the other you select
> the "2", but you can't highlight only the slash. Odd.

So after I posted my question, I fiddled around some more with TextEdit
and discovered that, while it is not possible to select only the
fraction slash character, it *is* possible to place the cursor ahead of
the entire fraction ("1/2") and then to selectively delete both the
numerals, leaving the fraction slash standing alone. Go figure.

That was the clue I needed. I did the same thing, copying the entire
fraction, pasting it into the proper part of my AppleScript, and then
deleting both the numerals.

Jolly's solution looks good, but my whole AppleScript is built around a
*long* list of text replacement operations, so isolating the character
gave me a solution that involved adding only one short line to the
script.

But an underlying problem is that the Mac badly renders text which
includes a fraction slash -- at least in the typefaces I use for my
recipe collection. If it hadn't looked so bad, I wouldn't haven't cared
(or even noticed) that the character was not just an ordinary slash.

Interestingly, the Language & Text/Text option to automatically replace
"big" fractions with "small" ones (multiple characters with a single
one) *does not work* if the fraction uses a fraction slash.

Isaac

Jolly Roger

unread,
Mar 20, 2015, 8:03:39 PM3/20/15
to
On 2015-03-20, isw <i...@witzend.com> wrote:
> In article <cn2mpp...@mid.individual.net>,
> Jolly Roger <jolly...@pobox.com> wrote:
>
>> On 2015-03-20, isw <i...@witzend.com> wrote:
>>
>> [Followups set to alt.comp.lang.applescript]
>
> I thought about that, but decided that the problem concerning the
> "fraction slash" was more of a global issue rather than something that
> just concerned AppleScript, since even TextEdit had problems with it
> (and see the last two paragraphs).

No problem. : )

>> TextEdit displays the fractions as overlapping, but it is not possible
>> to select only the slash -- if you put the cursor over the slash of
>> "1/2" and move it one way you select the "1", and the other you select
>> the "2", but you can't highlight only the slash. Odd.
>
> So after I posted my question, I fiddled around some more with TextEdit
> and discovered that, while it is not possible to select only the
> fraction slash character, it *is* possible to place the cursor ahead of
> the entire fraction ("1/2") and then to selectively delete both the
> numerals, leaving the fraction slash standing alone. Go figure.
>
> That was the clue I needed. I did the same thing, copying the entire
> fraction, pasting it into the proper part of my AppleScript, and then
> deleting both the numerals.

I just typed a fraction with the fraction slash character between two
numbers in TextEdit with the default Helvetica Neue font, and was able
to select only the slash with my trackpad.

> Jolly's solution looks good, but my whole AppleScript is built around a
> *long* list of text replacement operations, so isolating the character
> gave me a solution that involved adding only one short line to the
> script.

No worries. Just trying to help.

> But an underlying problem is that the Mac badly renders text which
> includes a fraction slash -- at least in the typefaces I use for my
> recipe collection. If it hadn't looked so bad, I wouldn't haven't cared
> (or even noticed) that the character was not just an ordinary slash.

They look fine in Helvetica and so on. Which fonts are you using?

> Interestingly, the Language & Text/Text option to automatically replace
> "big" fractions with "small" ones (multiple characters with a single
> one) *does not work* if the fraction uses a fraction slash.

That makes sense.

Your Name

unread,
Mar 20, 2015, 8:19:13 PM3/20/15
to
In article <isw-E13919.1...@news-roam.garlic.com>, isw
You can of course add your own automatic replacement option to work
with the fraction slash.

isw

unread,
Mar 20, 2015, 11:16:36 PM3/20/15
to
In article <210320151319109752%Your...@YourISP.com>,
Your Name <Your...@YourISP.com> wrote:

--snip--

> > Interestingly, the Language & Text/Text option to automatically replace
> > "big" fractions with "small" ones (multiple characters with a single
> > one) *does not work* if the fraction uses a fraction slash.
>
> You can of course add your own automatic replacement option to work
> with the fraction slash.

Well, sure, but I do think it's a bit ironic that a system function that
is presumably intended to make fractions "look better" fails completely
if the "proper" type of slash is used.

Isaac

isw

unread,
Mar 20, 2015, 11:20:23 PM3/20/15
to
In article <cn3qqp...@mid.individual.net>,
Lucida Grande, according to TextEdit, and I wasn't "using" it; it's what
came in from the web page that had the recipe.

> > Interestingly, the Language & Text/Text option to automatically replace
> > "big" fractions with "small" ones (multiple characters with a single
> > one) *does not work* if the fraction uses a fraction slash.
>
> That makes sense.

I hope you're making a funny. I just did a bug report to Apple about it.

Isaac

Jolly Roger

unread,
Mar 21, 2015, 8:40:50 AM3/21/15
to
Your presumption is wrong. The system function in question (System
Preferences > Keyboard > Text replacement list is a simple text
replacement function,and not a comprehensive fraction improvement
function. If you want it to handle more cases, you have to add those to
the list.

Jolly Roger

unread,
Mar 21, 2015, 8:49:00 AM3/21/15
to
I had assumed you were making reference to the System Preferences >
Keyboard > Text panel, where you can enter your own substitutions; but
now after re-reading, it seems like there is a specific setting
somewhere to replace fractions. I don't see that option in this
panel on my Mac Pro running 10.10 though:

<http://tinypic.com/view.php?pic=20u5nnk&s=8>

What am I missing?

Your Name

unread,
Mar 21, 2015, 4:57:14 PM3/21/15
to
In article <isw-2E469B.2...@news-roam.garlic.com>, isw
<i...@witzend.com> wrote:
> In article <210320151319109752%Your...@YourISP.com>,
> > >
> > > Interestingly, the Language & Text/Text option to automatically replace
> > > "big" fractions with "small" ones (multiple characters with a single
> > > one) *does not work* if the fraction uses a fraction slash.
> >
> > You can of course add your own automatic replacement option to work
> > with the fraction slash.
>
> Well, sure, but I do think it's a bit ironic that a system function that
> is presumably intended to make fractions "look better" fails completely
> if the "proper" type of slash is used.

Not really - most people don't even know there is a different slash,
let alone use it, so why bother wasting system time looking for
something that's extremely rarely going to be typed (especially since
in many fonts it probably doesn't even look any different, if it exists
at all).

isw

unread,
Mar 22, 2015, 12:47:59 AM3/22/15
to
In article <cn57lp...@mid.individual.net>,
Jolly Roger <jolly...@pobox.com> wrote:

> On 2015-03-21, isw <i...@witzend.com> wrote:
> > In article <cn3qqp...@mid.individual.net>,
> > Jolly Roger <jolly...@pobox.com> wrote:
> >> On 2015-03-20, isw <i...@witzend.com> wrote:
> >
> >> > Interestingly, the Language & Text/Text option to automatically replace
> >> > "big" fractions with "small" ones (multiple characters with a single
> >> > one) *does not work* if the fraction uses a fraction slash.
> >>
> >> That makes sense.
> >
> > I hope you're making a funny. I just did a bug report to Apple about it.
>
> I had assumed you were making reference to the System Preferences >
> Keyboard > Text panel, where you can enter your own substitutions; but
> now after re-reading, it seems like there is a specific setting
> somewhere to replace fractions. I don't see that option in this
> panel on my Mac Pro running 10.10 though:
>
> <http://tinypic.com/view.php?pic=20u5nnk&s=8>
>
> What am I missing?

You're looking in the wrong place. Try System Preferences/Language &
Text/Text.

Isaac

Your Name

unread,
Mar 22, 2015, 1:00:40 AM3/22/15
to
In article <isw-F748A2.2...@news-roam.garlic.com>, isw
It may depend on what version of OS X you're using ... Apple sometimes
moves things (or renames them) when they release new OS versions.

isw

unread,
Mar 22, 2015, 1:09:07 AM3/22/15
to
In article <220320150957100852%Your...@YourISP.com>,
It's an option that replaces a large version of a fraction composed of
three glyphs with a smaller, single one. Presumably, someone would
select that system option because they prefer the appearance of the
smaller version. Except that if the large fraction is typed "properly"
(with a fraction slash), then the replacement fails.

There has been, for years (starting in about 1984), a slow but
progressive tendency to move away from "typewriter" style text
formatting towards something more like what a typesetter would produce.
The use of the faction slash, along with a number of other character
shapes not available on a typewriter -- en dash and em dash, a large
variety of diacritical marks, etc., can be expected to continue to
increase.

But it takes a long time. There are still lots of folks who habitually
hit the space bar twice between sentences.

Isaac

Your Name

unread,
Mar 22, 2015, 2:19:23 AM3/22/15
to
In article <isw-8940AB.2...@news-roam.garlic.com>, isw
Most people don't know about a "fraction slash", so they simply type
fractions using the normal slash. Mac OS X has the option to replace a
fraction typed that way with a proper fraction character for those who
want it to do so.

The miniscule number of people who know about the fraction slash can
add their own replacement, but it's a bit worthless since it's a little
quicker to simply use a normal slash anyway. When they type a "fraction
slash" it's because that's what they want and don't want it replaced.



> There has been, for years (starting in about 1984), a slow but
> progressive tendency to move away from "typewriter" style text
> formatting towards something more like what a typesetter would produce.
> The use of the faction slash, along with a number of other character
> shapes not available on a typewriter -- en dash and em dash, a large
> variety of diacritical marks, etc., can be expected to continue to
> increase.

Maybe, but the vast majority of people simply don't know about them or
use them ... nor do they really care.

In some cases it's like the fraction replacement above. Someone types a
normal hyphen / minus sign and the software automatically replaces it
with a longer dash. The person typing doesn't even know or care that is
has been replaced.



> But it takes a long time. There are still lots of folks who habitually
> hit the space bar twice between sentences.

Yep, replacing double-spaces with a single space is usually the first
task in any documents I receive to work with.

Jolly Roger

unread,
Mar 22, 2015, 8:15:39 AM3/22/15
to
I think I'm looking in the right place for text substitutions.

There is no "Language & Text" panel in Mac OS X 10.10. There is a
"Language & Region", but that panel has no "Text" tab in it. It does
have an "Advanced" button where you can set the formats for numbers,
dates, and times. But there is nothing about fraction substitution in
there that I can see:

<http://tinypic.com/view.php?pic=j675e1&s=8>

<http://tinypic.com/view.php?pic=2ex0lz5&s=8>

The only panel that deals with substitution is the Keyboard system
preference panel I mentioned earlier - and there are no fractions listed
in it:

<http://tinypic.com/view.php?pic=20u5nnk&s=8>

This leads me to believe you are using an old version of Mac OS X -
perhaps 10.6. When I look at the system preferences in 10.6, I do see a
"Language & Text" system preference panel. And in the "Text" tab, I see
the same substitutions panel that now lives in the Keyboard panel in
10.10, where I do see fractions listed in the text substitution list:

<http://tinypic.com/view.php?pic=2z4fx21&s=8>

Which leads me back to what I said in another post: The text replacement
list is a simple text replacement function, and not a comprehensive
fraction improvement function. If you want it to handle more cases for
fractions with different characters, you have to add those to the list.

Michelle Steiner

unread,
Mar 22, 2015, 11:39:39 AM3/22/15
to
In article <cn7q39...@mid.individual.net>, Jolly Roger
<jolly...@pobox.com> wrote:

> The only panel that deals with substitution is the Keyboard system
> preference panel I mentioned earlier - and there are no fractions listed
> in it:
>
> <http://tinypic.com/view.php?pic=20u5nnk&s=8>

This is what I have in 10.10.3, and in every earlier system that I can
recall:

<https://dl.dropboxusercontent.com/u/50314006/Screen%20Shot%202015-03-22
%20at%208.38.28%20AM.png>

Jolly Roger

unread,
Mar 22, 2015, 11:47:50 AM3/22/15
to
Perhaps I removed them at some point.

Anyhow, like I said, this isn't a comprehensive fraction replacement
feature. It's simple text replacement, and if you want it to detect
anything other than the standard fractions that were apparently entered
with standard ASCII characters, you're going to have to add specific
entries to the list to do that.
Message has been deleted

David Empson

unread,
Mar 22, 2015, 11:51:49 PM3/22/15
to
Lewis <g.k...@gmail.com.dontsendmecopies> wrote:

> Okay, so one time? In band camp? Jolly Roger <jolly...@pobox.com> was all,
> like:
> They moved it (very recently) to Keyboard -> text. It might be as
> recently as the 10.10.3 beta, in fact, but I think they moved it earlier
> than that. Can't check 10.10.2 right now.

The substitutions were in Keyboard > Text starting in 10.9 (Mavericks).
Just confirmed on my 10.9.5 system. They were in Language & Text > Text
for 10.8.5 and earlier.

> > <http://tinypic.com/view.php?pic=20u5nnk&s=8>
>
> > This leads me to believe you are using an old version of Mac OS X -
> > perhaps 10.6. When I look at the system preferences in 10.6, I do see a
> > "Language & Text" system preference panel. And in the "Text" tab, I see
> > the same substitutions panel that now lives in the Keyboard panel in
> > 10.10, where I do see fractions listed in the text substitution list:
>
> > <http://tinypic.com/view.php?pic=2z4fx21&s=8>
>
> Very odd. You must have deleted them at some point in the past:
>
> <https://www.dropbox.com/s/hxog9cojszmo5i5/Screenshot%202015-03-22%2020.54.55.
> PNG?dl=0>

A fresh install of Mavericks or Yosemite doesn't have them by default
(but Mountain Lion does). The new defaults have just an "omw" for "On my
way!", same as the iPhone/iPad.

My current Yosemite system also has only the "omw" substitution, which I
didn't create so it presumably came from the new defaults. This system
was an upgrade from Mavericks, which was set up by migrating from my
previous computer which had been running Mountain Lion. I don't recall
offhand whether I had ever modified the previous default substituations,
but I expect I hadn't, beyond disabling most of them.

I do recall having the "omw" substitution rule while I was running
Mavericks.

It therefore looks like migration to Mavericks replaced the old default
substitutions with the new defaults (but perhaps upgrading doesn't,
which is why Lewis and Michelle still have them?).

I don't have enough evidence to judge what happened to any custom
substitution rules in a migration to Mavericks or Yosemite.


--
David Empson
dem...@actrix.gen.nz

isw

unread,
Mar 23, 2015, 12:27:03 AM3/23/15
to
In article <cn7q39...@mid.individual.net>,
10.8 in fact, but who's counting?

Isaac

Michelle Steiner

unread,
Mar 23, 2015, 12:42:34 AM3/23/15
to
In article <1m1qwfx.y41tmfoty87zN%dem...@actrix.gen.nz>, David Empson
<dem...@actrix.gen.nz> wrote:

> It therefore looks like migration to Mavericks replaced the old default
> substitutions with the new defaults (but perhaps upgrading doesn't,
> which is why Lewis and Michelle still have them?).

Well, I did upgrade rather than migrate.

Jolly Roger

unread,
Mar 23, 2015, 9:23:44 AM3/23/15
to
On 2015-03-23, Lewis <g.k...@gmail.com.dontsendmecopies> wrote:
> Okay, so one time? In band camp? Jolly Roger <jolly...@pobox.com> was all, like:
>
>> There is no "Language & Text" panel in Mac OS X 10.10. There is a
>> "Language & Region", but that panel has no "Text" tab in it. It does
>> have an "Advanced" button where you can set the formats for numbers,
>> dates, and times. But there is nothing about fraction substitution in
>> there that I can see:
>
> They moved it (very recently) to Keyboard -> text. It might be as
> recently as the 10.10.3 beta, in fact, but I think they moved it earlier
> than that. Can't check 10.10.2 right now.

Yep. It makes better sense to me to have the replacement list in the
Keyboard pane.

>> <http://tinypic.com/view.php?pic=20u5nnk&s=8>
>
>> This leads me to believe you are using an old version of Mac OS X -
>> perhaps 10.6. When I look at the system preferences in 10.6, I do see a
>> "Language & Text" system preference panel. And in the "Text" tab, I see
>> the same substitutions panel that now lives in the Keyboard panel in
>> 10.10, where I do see fractions listed in the text substitution list:
>
>> <http://tinypic.com/view.php?pic=2z4fx21&s=8>
>
> Very odd. You must have deleted them at some point in the past:
>
><https://www.dropbox.com/s/hxog9cojszmo5i5/Screenshot%202015-03-22%2020.54.55.PNG?dl=0>

I think I recall seeing them and saying to myself, "I can't think of a
time when I would like Unicode fractions and other symbols to be
injected into what I am typing", and removed them.

Jolly Roger

unread,
Mar 23, 2015, 9:25:53 AM3/23/15
to
On 2015-03-23, David Empson <dem...@actrix.gen.nz> wrote:
> Lewis <g.k...@gmail.com.dontsendmecopies> wrote:
>
>> Okay, so one time? In band camp? Jolly Roger <jolly...@pobox.com> was all,
>> like:
>>
>>> There is no "Language & Text" panel in Mac OS X 10.10. There is a
>>> "Language & Region", but that panel has no "Text" tab in it. It does
>>> have an "Advanced" button where you can set the formats for numbers,
>>> dates, and times. But there is nothing about fraction substitution in
>>> there that I can see:
>>
>> They moved it (very recently) to Keyboard -> text. It might be as
>> recently as the 10.10.3 beta, in fact, but I think they moved it earlier
>> than that. Can't check 10.10.2 right now.
>
> The substitutions were in Keyboard > Text starting in 10.9 (Mavericks).
> Just confirmed on my 10.9.5 system. They were in Language & Text > Text
> for 10.8.5 and earlier.

Sounds about right. Thanks.

> A fresh install of Mavericks or Yosemite doesn't have them by default
> (but Mountain Lion does). The new defaults have just an "omw" for "On my
> way!", same as the iPhone/iPad.
>
> My current Yosemite system also has only the "omw" substitution, which I
> didn't create so it presumably came from the new defaults. This system
> was an upgrade from Mavericks, which was set up by migrating from my
> previous computer which had been running Mountain Lion. I don't recall
> offhand whether I had ever modified the previous default substituations,
> but I expect I hadn't, beyond disabling most of them.
>
> I do recall having the "omw" substitution rule while I was running
> Mavericks.
>
> It therefore looks like migration to Mavericks replaced the old default
> substitutions with the new defaults (but perhaps upgrading doesn't,
> which is why Lewis and Michelle still have them?).
>
> I don't have enough evidence to judge what happened to any custom
> substitution rules in a migration to Mavericks or Yosemite.

Very interesting. At any rate, I say good riddance to them!
0 new messages