Wednesday, 19 May, 2004
Windows' broken search tools
I have a standard set of tools that I usually install on any machine that I'll be working with on a regular basis. This set of tools is a hodge podge of stuff I've collected over the years, either written by me or acquired by other means. The tools include a text search utility (grep), a hex file viewer (my home-grown DUMPJ program), an ASCII chart display (surprisingly, I still use that), file comparer, and various other odds and ends that I've found useful over the years. Some of these tools are showing their age and don't work particularly well with modern systems, but most of them are still quite useful. I haven't installed those tools on my development machine at work because they frown on "unauthorized" software installs. I'll eventually get the OK to install them here, but in the meantime I'm limited to what comes with Windows and Visual Studio .NET.
My task today was to find all the "RAISERROR" statements in all of the project's stored procedures, which are stored as text files in one of the project directories. "If I had grep," I thought, "I'd just use it in that directory." Since I don't have grep, I tried to use Windows Explorer. No dice. It reported no matches when I know for a fact that at least some of the files contain that statement. Then I found the Windows FINDSTR command, which is something of a bastardized grep. After fooling with the syntax for a while, all to no avail, I'd almost given up. Then it occurred to me that the stored procedures are saved in Unicode rather than plain old ASCII text. Sure enough, if I opened a file in Notepad and saved it as straight text, FINDSTR and Windows Explorer worked as expected. So now I'm sitting here wondering how Microsoft managed to ship a Unicode-enabled Notepad with Windows 2000, but still hasn't managed to add Unicode support to their text search programs.
I did eventually solve my problem, by the way. I used the "Find in Files" functionality of Visual Studio .NET to find what I needed. I find it incredibly annoying to start Visual Studio in order to search for files that contain particular strings, especially when Microsoft is beginning to use Unicode in many more situations. My hope is that Longhorn's tools will fix this shortcoming.