ToLower - A HTML Compatibility Tool

Environment: VC6 SP4, Win9x NT4 SP5, Win2k

In General How It Works Usage
Source Code Full Version Credits

ToLower was created when I tried to port a website from a Windows to an LINUX/UNIX platform and experienced some annoying compatibility problems.

This is due to the Windows file system's habit, not to distinguish between lower and upper case file names (it's "case insensitive") and that it allows characters (e. g. "?", "!" and "-") that have a special function in UNIX and are therefore reserved.

ToLower parses one or more HTML-files that are specified on its command-line for regular expressions (regex courtesy of Henry Spencer, some slight cosmetic changes to the code done by me) that contain <a href="filename.htm"> Text </a>, <img src="filename.htm"> or <body backgound="filename.htm"> Text </body> - tags, corrects the case and other extras that could affect compatibility.

After that, all referenced files (respective their names) are adapted according to the changes done in the HTML file.

Finally, all other files in the path of the specified HTML-file(s) are renamed to their lower-case (compatibility) file names to avoid ambiguities.

The ToLower source code contains some interesting and recyleable bits of code that I thought I should share with you:

  • CStrList Class for generating a list of strings. Has various insertion, appending, sorting, searching and deleting functions. Files: cstrlist.h, cstrlist.cpp
  • regex
  • A full featured regular expression searcher. Necessary files: cclass.h, cname.h, engine.c, regcomp.c, regerror.c, regex.h, regex2.h, regexec.c, regfree.c, utils.h. Usage is pretty self-explaining (take a look at the
    // search for regular expression that

    -section of tolower.cpp.

  • str2list
  • Converts a delimited string to a list of elements. Useful when parsing command lines. Files: str2list.h, str2list.cpp and the CStrList-class.
  • TempNamA
  • Creates unique temporary file name. Files: tempnama.h, tempnama.cpp.
The usage of ToLower is simple:

Just list every HTML-file that has to be checked/changed on the command line. To change all files in the path, we would do a

dir /s /b *.htm *.html > tolower.bat

and insert a

tolower

prior to each file name (don't forget the space char after "ToLower"). A call to

ToLower.bat

does the trick!

Of course, ToLower supports absolute and relative paths.

Credits: My credits go to Henry Spencer for the regular expression search engine, to Chris Windmüller for CStrList and all the other open source programmers that are never mentioned in any commercial projects.

If you have any comments, improvements or complaints - feel free to send me an email. Have fun!

Volker.

Downloads

Complete VC6 project: ToLowerSrc.zip (50 kBytes)
Compiled executable: ToLowerExe.zip (80 kBytes)


Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds