Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

scanf field width

Name: Anonymous 2013-09-20 10:45

For the %s conversion specifier, is the field width in bytes or characters? The C standard is suggesting that the field width is always measured in characters, but there's this small note that confuses me:
246) No special provisions are made for multibyte characters in the matching rules used by the c, s, and [ conversion specifiers — the extent of the input field is determined on a byte-by-byte basis. The resulting field is nevertheless a sequence of multibyte characters that begins in the initial shift state.
Also, the opengroup documentation seems to be suggesting (see the description given for the %c specifier as well) it's in bytes if no l length modifier is present. Otherwise, it's in characters.

plz help me lambda‼

Name: Anonymous 2013-09-23 9:09

>>15
I meant the standard isn't clear about the whole thing i.e. the other case (without the l modifier) included. The only hint that ``character" in that context means single-byte character is that ``multibyte" isn't explicitly mentioned (and perhaps the note I quoted).

Side note: I wonder how multibyte character to wide character conversions are done in Windows. The wchar_t type is 16 bits and uses UTF-16. If a multibyte character is outside Unicode's BMP (is it possible with ANSI code pages? If not, char* could still use UTF-8, right?) then it has to be coded as a surrogate pair.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List