开发者

How to write a file with CRLF line breaks in Objective-C?

I need to create and export an excel file in my iPhone app. Unfortunately, excel won't read it if the line encoding is LF (the unix def开发者_开发知识库ault when I write the file) instead of CRLF (the Windows standard)...Is there any way to write a file using CRLF line breaks?

I can tell this is the issue as if I open the file in TextWrangler after outputting it, then change the line breaks to CRLF, excel opens it fine.

Thanks,

Toby


If you're using printf or fprintf in C you typically terminate lines like this:

printf( "this is a line of text.\n" );

The \n outputs a linefeed. You can output a carriage return with \r, so to get a CRLF, you just:

printf( "this is a CRLF terminated line.\r\n" );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜