PTC MKS Toolkit Knowledge Base

Section:IO
Product:MKS Toolkit (TKPDev/TKEDev)
Version:
OS:All
Keywords:line feed, carriage return, crlf
Category:Porting/Knowledge Base


Why do text files have carriage returns in them?


UNIX uses a single line-feed character (\n) as a line delimiter in text files, while Windows uses a carriage-return/line-feed pair (\r\n) to delimit text lines. This can cause problems when porting code that assumes that a line-feed terminates a text file. To address this issue, MKS Toolkit porting products support opening files in text mode. When a file is opened in text mode, reading from the file will convert carriage-return/line-feed pairs to single line-feeds, while writing to the file will convert single line-feeds to carriage-return/line-feed pairs. Refer to Text Files and Binary Files in the Windows Concepts chapter of the UNIX to Windows Porting Guide.

MKS Toolkit products also include the flip.exe utility for converting text files between UNIX and Windows format.