(Related Resources)
Line 109: Line 109:
 
==Related Resources==
 
==Related Resources==
 
*[[Convert_Fixed_Length_Records|Convert Files with Fixed-Length Records]]
 
*[[Convert_Fixed_Length_Records|Convert Files with Fixed-Length Records]]
 +
*[[Window_Unix_Text_Files|Windows/DOS and UNIX Text Files]]

Revision as of 16:11, 10 February 2017


This article shows how to convert between different file types and perform other useful conversions.

  • Converting between Windows/DOS, UNIX/Linux and Macintosh text files.
  • Converting from fixed-length records into normal text files.
  • Converting a text file into fixed-length records.
  • Padding a text file to make all lines the same length.
  • Stripping trailing spaces from a text file.

vEdit supports Windows/DOS, UNIX/Linux and Mac text files. Main differences between them are the “newline” characters used at the end of each line. vEdit also supports data files with fixed-length records.


Confirm File Type

When opening a file, vEdit automatically determines the most likely file type. It can usually determine the correct file type for text files (Windows/DOS, UNIX/Linux or Mac). It is highly recommended confirming the file type before doing file converting.

1. Move the cursor to the end of a line 2. Press Alt-D (the hot-key for View > Toggle display mode)

You can now see the hex codes for the “newline” characters, if any. “0D” is the hex code for Carriage-Return. “0A” is the hex code for Line-Feed.

Windows / DOS
If each line ends in “0D 0A”, you have a Windows/DOS text file.
Linux / UNIX
If each line ends in just “0A”, you have a UNIX text file.
Apple Mac
If each line ends in just “0D”, you have a Mac text file.

If you don't see “0D” or “0A”, then you must have already explicitly set a record-length with CONFIG > File handling > File type.

3. Double-check that CONFIG > File handling > File type is set to the correct file type.

Windows/DOS
Windows set to “0”
Linux / UNIX
Linux set to “1”
Apple Mac
Mac set to “2”

Otherwise, it is set to the data file's record length.

Easy-To-Use Windows / UNIX Convert Function

Since converting between Windows/DOS and UNIX text files is very common, vEdit provides the easy-to-use functions:

Convert Win / DOS to UNIX in 3 just steps, Click EDIT, Convert then Win/DOS to UNIX

or

Convert UNIX to Win / DOS by clicking EDIT, Convert then UNIX to Win/DOS.

Convert Between Files Types

Converting Windows/DOS, Mac, and UNIX/Linux files is made easy with vEdit's Convert Macro (Convert between File Types):

1. To convert the entire file, click Block then Select all ( hot-key: Ctrl-A) to block highlight the file.


You can convert a file without highlighting a section, but you will be prompt when opening the converter "OK to convert entire file?"

Convert Entire File.png


2. Once you have what you wish to convert highlighted, click Edit, Convert, then select Convert Macro.

3. Select the desired conversion by entering the corresponding number "1" through "8".

"Convert between File Types - These functions convert all "newlines" in the highlighted block between Windows/DOS (CR+LF), UNIX (LF only) and Macintosh (CR only)."

Each conversion has an assigned number, 1-8:

1
DOS to UNIX (CR+LF to LF)
2
DOS to Mac (CR+LF to CR)
3
UNIX to DOS (LF to CR+LF)
4
UNIX to Mac (LF to CR)
5
Mac to DOS (CR to CR+LF)
6
Mac to UNIX (CR to LF)

These functions convert fixed-length records:

7
Fixed-length records to Newlines (Before selecting “Fixed-length to Newlines”, you must set the correct record-length.)
8
Newlines to fixed-length


Convert Between File Types.png

Sometimes you don't want to convert the entire file, but only a block. For example, if you “cut and paste” a block from a UNIX file into a Windows/DOS text file, you will have to convert that block.

If you accidentally perform a “UNIX to Win/DOS” conversion on a file which is already a Win/DOS text file, each line will then incorrectly end with two Carriage-Returns and one Line-Feed. This can be fixed.

To fix a Windows/DOS text file which has extra Carriage-Returns:

  1. Select EDIT > Convert > Win/DOS to UNIX several times to remove all Carriage-Returns.
  2. Then select EDIT > Convert > UNIX to Win/DOS exactly once.

Related Resources