Please help me DELETE SPACES in text

When copying text from a website, it appeared in Appleworks with a space between each character.
Can I automatically delete these many thousand spaces - apart from individually for each space ?

Thanks,
Bramble24

iMac, Mac OS X (10.6.6), 2.8 GHz Intel Core 2 Duo

Posted on Feb 11, 2011 9:31 AM

Reply
4 replies

Feb 11, 2011 11:54 AM in response to casablanca24

The difficulty here is to delete all the 'extra' spaces without deleting the 'needed' spaces.

Press command-; to show the invisible characters (including all the spaces), and check the ends of words and sentences and other places where there should be spaces when you're done. If you find multiple spaces at these locations, you should be able to fix things in three passes of find/change.

Press command-F to open the Find/Change dialogue.

Pass 1:
Find: enter two spaces
Change: enter ##
Click Change All.
OK the warning and the alert telling how many changes were made.

Pass 2:
Find: enter one space
Change: clear this box.
Click Change All.
OK the warning and the alert telling how many changes were made.

Pass 3:
Find: enter ##
Change: enter one space
Click Change All.
OK the warning and the alert telling how many changes were made.

That should do it.

Regards,
Barry

Feb 19, 2011 8:34 AM in response to casablanca24

I guess that you copied text using UTF16 encoding.
In such kind of datas, for the old ASCII set of characters, the modern encoding insert a nil byte before the old ASCII value.
AppleWorks replace these nil characters by space ones.

Try to apply this script before pasting

--

--=====
on run
set en_texte to the clipboard as text
--set en_texte to my supprime(en_texte,ASCII character(0))
set the clipboard to en_texte
end run
--=====
(*
removes every occurences of d in text t
*)
on supprime(t, d)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end supprime
--=====
--


If the result is OK, you may replace it by my good old Huge friend :

--

--=====
on run
set the clipboard to the clipboard as text
end run
--=====
--


If the result is always odd, try to remove the two minus character which I typed in front of
set en_texte to my supprime(en_texte,ASCII character(0)).

The script will become :

--

--=====
on run
set en_texte to the clipboard as text
set en_texte to my supprime(en_texte,ASCII character(0))
set the clipboard to en_texte
end run
--=====
(*
removes every occurences of d in text t
*)
on supprime(t, d)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end supprime
--=====
--


This time, the extraneous nil bytes will be removed and you will get a clean text.

Yvan KOENIG (VALLAURIS, France) samedi 19 février 2011 17:34:43

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Please help me DELETE SPACES in text

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.