Entering Non-Printable ASCII Characters Into Text Files Under Windows (With MS-DOS Editor)

When editing a text file in Windows it is sometimes necessary to embed special non-printable ASCII control characters into the text. This is quite difficult in modern Windows versions. Windows does not allow any way to enter codes below code 032 (space) into standard text fields. Newer NT based versions of Windows also use UNICODE strings internally, which does not support lower ASCII control codes.

Notepad supports entering some of the character codes using ALT key codes. You hold down the ALT key and enter in the three digit ASCII code for the character on the numeric keypad. Number Lock must be turned on and you have to enter the numeric code on the numeric keypad (it will not work using the regular number keys). For example, to enter in a carriage return you can use ALT+013 or to enter in a line feed character, you can use ALT+010. Notepad allows a few ASCII control codes to be entered this way, but you cannot use all of them.

The best way that I’ve found is to use the MS-DOS Editor program (edit.com). MS-DOS Editor is still included with all 32-bit version of Windows. You can open it by entering ‘edit’ in the run box or command prompt.

In MS-DOS Edit you can use CTRL-P and then enter an ASCII control code which will be embedded into the text file. You can enter the code as an ALT key code or an ASCII control code,  a list of ASCII control codes is available here. So to enter the Form Feed character for example, you would press CTRL-P and then CTRL-L (or CTRL-P and ALT+012). It will place a symbol in the editor to represent the non-printable ASCII character. When you save the file in the MS-DOS Editor it will save the embedded character codes in the text file.

Once the file is saved you can re-open it in a Windows editor which supports ASCII text files like Notepad or ConTEXT. The symbol will be displayed in the editor and you can copy and paste it into other text files to embed the control code into them.

Be warned that many Windows programs and text boxes may attempt to convert the character code into something else when you copy and paste it (I believe it may have to do with Windows converting it to UNICODE). For example, when I copied the form feed (code 12) character directly from a console running DOS Edit, it pasted into other Windows applications as “?” (code 63). Notepad even displayed a similar character to the one in DOS Edit but it still was as a different character (not code 12) when I checked. Also, when I copied the character from a file opened in ConTEXT, it pasted into Notepad properly (as code 12), but pasted into the Visual Studio IDE as “?” (code 63).

3 Responses to Entering Non-Printable ASCII Characters Into Text Files Under Windows (With MS-DOS Editor)

  1. Angad says:

    Hey Keith,
    Thanks for the post. You wont believe hat I had been struggling since like 3-4 days trying to find ways to print Escape Sequences in MS-DOS Edit program. But just couldnt google that good…..until I found your page.

    Really appreciate your effort.
    Thats a lot once again
    Angad

  2. zernager says:

    I also like Notepad++ with its “Insert ASCII Chart or Character” TextFX tool. That inserts an array of characters that can be copy and pasted.

  3. Martin says:

    It’s worth noting that MS-DOS Edit no longer comes with windows.

Leave a comment