Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • File read limits.

    Dear All,

    Stata's manual mentions that:

    fget(fh) is for reading text files; the next line from the file is returned, without end-of-line characters. (If the line
    is longer then 32,768 characters, the first 32,768 characters are returned.)

    fgetnl(fh) is much the same as fget(), except that the new-line characters are not removed from the returned result. (If
    the line is longer then 32,768 characters, the first 32,768 characters are returned.)


    Is there any way to reliably determine if this trimming of content has actually occurred during the reading?

    Thank you, Sergiy

    Last edited by Sergiy Radyakin; 12 Mar 2023, 23:49.

  • #2
    I suppose that you could read a line with fget() (with end-of-line characters), then use ftell() for diagnosis:

    If you're shy of 32 768 bytes from the beginning of the file (or from the end of the previous line read), then you're okay.

    Else (i.e., if you're at 32 768)
    If the last characters that you've read are not end-of-line characters, then you've truncated the line
    Else you're okay.
    I'm not sure whether "character" in this context means single-byte (ASCII / ANSI) or Unicode UTF-8. I assume the latter.
    Last edited by Joseph Coveney; 13 Mar 2023, 07:03.

    Comment


    • #3
      Dear Joseph,

      thank you very much! This approach is going to be helpful for my task.

      Best, Sergiy

      Comment

      Working...
      X