0

In ICU4C,

UChar * u_fgets(UChar *s, int32_t n, UFILE *f)

will read one line from f into buffer s, which size is n.

But how can I know this one line's length ?

What will happen if n is not enough for this one line ?

linrongbin
  • 2,967
  • 6
  • 31
  • 59
  • 1
    Hopefully the same as the usual `fgets()` - the last character will be a newline if a complete line was read, and the last character actually read if there wasn't enough space for a full line. But check the documentation. – Shawn Oct 22 '19 at 03:31

1 Answers1

1

But how can I know this one line's length ?

If u_fgets() works similarly to the standard fgets() it will put a '\0' after the last character read. Then you can get the length by calling strlen() or its equivalent version for your system.

What will happen if n is not enough for this one line ?

If u_fgets() works similarly to the standard fgets() it will stop filling characters into the buffer s so that '\0' gets into the last cell. This will be the nth character at s[n - 1]. Characters not stored will remain in the input stream f.


However, please read the documentation! That is always your first stop.

the busybee
  • 10,755
  • 3
  • 13
  • 30