[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test needed - fileread and line endings
From: |
Mike Miller |
Subject: |
Re: test needed - fileread and line endings |
Date: |
Thu, 30 Jun 2016 12:22:19 -0700 |
User-agent: |
Mutt/1.6.0 (2016-04-01) |
On Fri, Jul 01, 2016 at 00:39:39 +0530, Abhinav Tripathi wrote:
> On Jul 1, 2016 12:30 AM, "Mike Miller" <address@hidden> wrote:
> >
> > Can someone test the following for me in Matlab? I'm interested in the
> > output on both Windows and Unix-like systems.
> >
>
> On Matlab2013a on Windows 10 I get:
>
> > fid = fopen('foo.txt', 'wb');
> > fprintf(fid, 'a\nb\n');
> > fclose(fid);
> > fid = fopen('bar.txt', 'wb');
> > fprintf(fid, 'a\r\nb\r\n');
> > fclose(fid);
> > info = dir('foo.txt');
> > info.bytes
>
> ans = 4
>
> > info = dir('bar.txt');
> > info.bytes
>
> ans = 6
>
> > s = fileread('foo.txt');
> > double(s)
>
> ans = 97 10 98 10
>
> > s = fileread('bar.txt');
> > double(s)
>
> ans = 97 13 10 98 13 10
Yikes. Ok, thank you, I wrongly assumed Windows would convert the line
endings here, I'll take care of that.
--
mike