How do I remove a rogue character from my text (CSS) files?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
ship69
Posts: 5
Joined: Sun Mar 04, 2012 10:30 pm

How do I remove a rogue character from my text (CSS) files?

Post by ship69 »

Hi

How can I find and remove a rogue character from my .CSS plain text files?

The character is called "INFORMATION SEPARATOR FOUR" or "file separator" or Alt/028 ( http://www.fileformat.info/info/unicode ... /index.htm )

The problem is that the presence of this character is screwing up my desktop searching utility (X1 Search) and I can't maintain my numerous CSS files without this.

In fact I can duplicate the problem in TextPad (7.2) by entering the character by holding down Alt and hitting 028 on numeric keyboard.

My problem however is how do I find and replace these characters that have infected a number of my CSS files? Because (unsurprisingly) you cant enter Alt/028 into the search and replace box in TextPad!

Any thoughts?

J

P.S. eg are there any utilities out there that are designed to do this sort of cleanup? It would be nice to be able to clean up multiple files at once... !
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post by ak47wong »

You can search for and replace your "file separator" (FS) character with its hex value of 1C:

Find what: \x1c
Replace with: (nothing)

Select Regular expression.
Click Replace All.

To make the change in multiple files you can use WildEdit.
ship69
Posts: 5
Joined: Sun Mar 04, 2012 10:30 pm

Post by ship69 »

I have no idea how you worked that out but yes that seemed to work... brilliant!

Now, is there a way to do a search and replace across all files in a directory?
Or even all files within a directory tree?

Many thanks

J
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You can also select the character and run a search (which will use the current selection if it is within a single line), or copy the character and paste it into the Find What box. If you do it that way Regular expression does not need to be selected.

Can you be specific about which parts of the help under How To... | Find and Replace Text | Find in Multiple Files are unclear?
ship69
Posts: 5
Joined: Sun Mar 04, 2012 10:30 pm

Post by ship69 »

ben_josephs wrote:You can also select the character and run a search (which will use the current selection if it is within a single line), or copy the character and paste it into the Find What box. If you do it that way Regular expression does not need to be selected.

Can you be specific about which parts of the help under How To... | Find and Replace Text | Find in Multiple Files are unclear?
Ben
1. If you try to copy and paste this the rogue character (created by Alt/028)
into the "Find what:" search box, this fails. That was the first thing I tried!

2. In fact you can not enter the character into the same box this fails too.

3. Even if you select just the character in question and then hit F8 you get odd results because what appears in the "Find what:" field is the character BEFORE the rogue character that you thought you had selected.

Odd things happen when you try to delete this rogue character too because it seems to appear on screen once character AFTER it's true location.

If you'd like a constructive suggestion,
A) please can we use more standard keyboard defaults for the F keys. e.g. Control/F for Find and Control/R for replace. (I always am forced to change these settings manually on my installations, which is painful.)

B) If the user hits "?" in that Replace popup window, given that it doesn matter what the heck you click next in that window but that it always goes to the exact same help screen, when do you even have that extra click? i.e. What is the point of changing the mouse pointer to a "?" if you go to the same place regardless of what you click on .

Regarding regular expressions, it was irritating to NOT be taken to an explanation of what a regular expression is when you click on the "?" and then on the words "regular expression" - i.e. the user has to search manually for "regular expression". Regular expressions are a rather complex subject and I only half understand them but either way I still cant work how ak47wong worked out that "\x1c" means "file separator".

P.S. Knowing the answer \x1c, I did just manage to find a page talking about POSIX symbolic names. On this page it talks about "IS4" (rather than "file separator" or "Information Separator Four" or Information Separator 4") and the value given has a capital C which may or may not be important...

Trying to help

J
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Ah. I see the problem with selecting and deleting that character. I tried it with that character alone on a line, and then all works as I described (with TextPad 7.3.0, 64 bit). This is a bug that you should report to Helios (I don't work for them).

The operation of context-sensitive help is also a matter for Helios. You might make a suggestion in the Enhancement Suggestions forum. Don't hold your breath.

The value of the character you don't want is, as you say, 28 in decimal, which is 1C in hexadecimal. If Regular expression is selected in the Find or Replace dialogue you can use the notation \x1C (or \x1c) to represent this character.
ship69
Posts: 5
Joined: Sun Mar 04, 2012 10:30 pm

Post by ship69 »

This is a bug that you should report to Helios (I don't work for them).


How does one do that? Can't I just point them to this thread? Come to think of it don't they bother to read their own forums?

J
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Try emailing support@textpad.com .
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post by ak47wong »

ship69 wrote:If the user hits "?" in that Replace popup window, given that it doesn matter what the heck you click next in that window but that it always goes to the exact same help screen, when do you even have that extra click? i.e. What is the point of changing the mouse pointer to a "?" if you go to the same place regardless of what you click on.
This behaviour is peculiar to version 7 of TextPad. In previous versions, the Find and Replace dialogs had an actual Help button, which would open the help file immediately. For some unknown reason, in version 7 they replaced this with a "?" icon in the title bar, which appears at first to work like Windows XP context sensitive help, but doesn't. Apart from being confusing it's also inconsistent, as none of the other dialogs has a "?" icon and most still have a Help button, e.g. Page Setup, Compare Files, Spelling, Run and Preferences.
ship69 wrote:Regarding regular expressions, it was irritating to NOT be taken to an explanation of what a regular expression is when you click on the "?" and then on the words "regular expression" - i.e. the user has to search manually for "regular expression".
The help for the Find dialog contains a link to the Regular Expression help page. Unfortunately, the help for the Replace dialog doesn't, and that's something that hasn't changed in this version. You're expected to click the link for Finding Text first and then click the Regular Expression link.
User avatar
bbadmin
Site Admin
Posts: 1020
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Post by bbadmin »

The problem with the Alt+028 is that Windows does not render it, even as a space, but TextPad’s calculation of the length of the string containing it includes that character. The effect is to leave space at the end of the string, which is confusing.

Microsoft have avoided the problem in edit controls by not allowing that character to be input, so it can’t be typed in the Find dialog box. It's possible there are other characters that misbehave in this way.

Ben_josephs’s workaround of searching for \x1c works.

We will fix the problem with context sensitive help.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Thanks for the explanation.

In fact, it was ak47wong who suggested \x1c.
Post Reply