Find in Files is not finding text in one particular file

General questions about using TextPad

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

Post Reply
ztodd
Posts: 9
Joined: Tue Jan 04, 2011 9:52 pm

Find in Files is not finding text in one particular file

Post by ztodd »

It's a plain text search- the text is definitely in that file- but the Find in Files function seems to just skip over that file or something.

I tried renaming the GUIState.xml file as mentioned in the other thread I found, but the problem still remains.

The permissions are exactly the same on this file as they are on another file that the Find in Files function successfully returns to me.

I used the "Find" command on the command line to see if it would work- and it does (it shows that the text is found in the file in question).

Other ideas to troubleshoot?

add'l info:
I found that the "findstr" command has the same quirk when I use it on a command line. I'm guessing that Textpad's Find in Files function actually uses the "findstr" command as it's engine. In that case, I guess the bug would actually be with the findstr command.

I'll see if I can reproduce the issue with a couple of small, simple files...

I'm using Windows Server 2008 R2 Enterprise, Service pack 1.

Here is proof -

Code: Select all

F:\Programs\Utils>type "F:\tech\temp\testsearch.sql"

/*  Tables updated:
                ,[Instar follow ups],
*/

F:\Programs\Utils>findstr /c:"Instar follow" "F:\tech\temp\*.sql"

F:\Programs\Utils>find "Instar follow" "F:\tech\temp\*.sql"

---------- F:\TECH\TEMP\TESTSEARCH.SQL
                ,[Instar follow ups],

F:\Programs\Utils>
The "find" command finds it, but the "findstr" command does not. Can anyone else reproduce this same issue?

More add'l info:

Code: Select all

F:\Programs\Utils>findstr /c:"In" "F:\tech\temp\*.sql"

F:\Programs\Utils>findstr /c:"I" "F:\tech\temp\*.sql"
 :\tech\temp\testsearch.sql:             , [ I n s t a r   f o l l o w   u p s ] ,
It appears that it might be related to the file being in unicode...
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

The text in your file is encoded in Unicode UTF-16: each character is encoded in 2 bytes (16 bits). TextPad's Find In Files and Windows' findstr don't work with double-byte-character files.

From the help, under How To... | Find and Replace Text | Find in Multiple Files:
You can search for strings in either text (excluding Unicode) or binary files

The spaces in the output from findstr in your last example are a give-away. Those spaces represent the null (zero) bytes of each byte pair.
ztodd
Posts: 9
Joined: Tue Jan 04, 2011 9:52 pm

Post by ztodd »

Thanks for that link to the help file ben- I probably should've checked there first thing. :)

Do you think there'd be any chance of the Textpad programmers changing their code for that to be able to support searching unicode files? Or if there's any chance of Microsoft upgrading their findstr command to support seraching unicode files?

I figure the former case may be more likely than the latter.
ztodd
Posts: 9
Joined: Tue Jan 04, 2011 9:52 pm

Post by ztodd »

If this helps anyone, I made this small batch script to convert all my files from unicode to ansi - you can change the file extension for what you need -

Code: Select all

for %%f in (*.sql) do (
	type "%%f" > "%%~nf_ansi.sql"
	del "%%f" 
	ren "%%~nf_ansi.sql" "%%f" 
)
Post Reply