CRLF: Text Converter Unix->Windows for XP

(c) 2002 Lucian Wischik. These programs are free, and anyone can do with them whatever they like (except sell them or claim ownership).

Unix-format text files do not load properly into Notepad: their linebreaks are wrong. The problem is that unix expects linebreaks in the 'LF' format (\n), while Windows expects them in the 'CRLF' format (\r\n). The programs on this page provide two possible ways to convert LF into CRLF. You can use either program its own, or both together. They require Windows XP.

crlf-interceptor-setup.exe (72k) - Download this setup program, and run it. Every time you double-click on a .txt file, the interceptor will quickly check whether it's LF format and if so will offer to convert it to CRLF. You can configure it to work with any other file extension as well. The program uses no system resources except for a very brief check each time you double-click on a file. Advantage: this technique works with all filetypes used by all programs. Limitation: this technique only works with double-clicking on the file; it doesn't work with doing View|Source from Internet Explorer for instance, nor for the Send-To menu. Note: After installation, you can delete the setup program.

crlf-notepad.exe (72k) - This program acts as a wrapper around Notepad. To install it, first rename notepad.exe -> notepad-orig.exe and then rename crlf-notepad.exe -> notepad.exe. In this way, whenever any program thinks it is launching notepad, it will really be launching the CRLF wrapper first. Advantage: works no matter how notepad is invoked, be it from Internet Explorer's View Source menu or Send-To. Limitation: only works with notepad.

The source code for both programs is available: (35k). They are written in plain Win32 API, with project-files for Visual Studio .NET. I write out their keywords so that other programmers will find them when looking for example code: UNICODE, SHGetFileInfo, SHFILEINFO, LoadIcon, LoadImage, memory mapping, RegOpenKeyEx, RegCreateKeyEx, list class, string class, DialogBox, CoInitializeEx, IMalloc, ITEMIDLIST, SHGetSpecialFolderLocation, SHGetPathFromIDList, shortcut, IShellLink, CSIDL_PROGRAMS, BROWSEINFO, SHBroseForFolder, initial directory, initial folder, Uninstall, UninstallInfo, CoCreateInstance, CLSID_ShellLink, IID_IPersistFile, MultiByteToWideChar, MoveFileEx, MoveFileExA, kernel32.dll, MOVEFILE_DELAY_UNTIL_REBOOT, WritePrivateProfileString, wininit.ini, rename, GetCommandLine, GetAsyncKeyState, GetFileAttributes, SetFileAttributes, FILE_ATTRIBUTE_READONLY, CreateFileMapping, MapViewOfFile, CloseHandle, UnmapViewOfFile, SetFilePointer, SetEndOfFile, truncate file size, STARTUPINFO, PROCESS_INFORMATION, CreateProcess, \n, \r\n.