0

I'm writing a script to check for dos line breaks, in a unix environment. however, I dont have a sample to check my test cases. How do I create one?

2 Answers 2

2

Load Vim, write a few lines of text, then:

:set fileformat=dos :w 

Use hexdump -C if you want to verify that the resulting file does contain CRLF.

Sign up to request clarification or add additional context in comments.

Comments

1
fprintf(fp,"something\r\n"); 

or

data[n++]=0x0D; data[n++]=0x0A; fwrite(data,1,n,fp); 

or have a program like this

rb=fread(datain,1,sizeof(datain),fpin); if(rb==0) break; rc=0; for(ra=0;ra<rb;ra++) { if(datain[ra]==0x0A) { dataout[rc++]=0x0D; } dataout[rc++]=datain[ra]; } fwrite(dataout,1,rc,fpout); 

dataout has to be twice as big as datain just in case.

it is far easier just to tell your text editor to do it, open the file then save or save as after changing the format for that file. The scintilla based editors, scite, geany, notepad++, have no problem with it (geany makes it very easy on a document by document basis). looks like vi and probably emacs will work. Textpad no problem.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.