Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
dpb
Posts:
6,677
Registered:
6/7/07
|
|
Re: textscan: handling spaces in fixed-width data
Posted:
Jan 7, 2013 10:36 AM
|
|
On 1/7/2013 6:46 AM, David wrote: > Hi dpb, Thanks for your messages! It really appears strange, that > textscan handles the space different than other characters while scanning. ...
It's an unfortunate wart that comes from Matlab being written in C and therefore using the *scanf() functions in the C i/o library and runtime.
I finally did find the normative text in the C Standard so it can't even be blamed on a bad implementation; it's the result of a (misguided imo) choice in the language definition to "eat" white space on the apparent assumption that all input should be delimited--
From the C99 Standard (C99 7.19.6.2p8:)
> Input white-space characters (as specified by the isspace function) > are skipped, unless the specification includes a [, c, or n > specifier.241)
I've commented for years about not having an alternate Fortran-like FORMAT specification that would solve many of the problems w/ the C format strings (like also not being able to have repeat specifiers but having to resort to the butt-ugly repmat() nonsense) that would fix the problem but the seeds have fallen upon barren ground it seems...
--
|
|
|
Date
|
Subject
|
Author
|
|
1/3/13
|
|
dpb
|
|
1/3/13
|
|
dpb
|
|
1/4/13
|
|
dpb
|
|
1/7/13
|
|
dpb
|
|
|