Julio Batista Julio Batista - 1 year ago 73
C Question

What exactly does '%Id' mean? (uppercase I, lowercase d)

I'm asking about

, not

Can anyone please explain to me what does "I" exactly do:

For decimal integer conversion (
) the output uses the
locale's alternative output digits, if any. For
example, since glibc 2.2.3 this will give Arabic-Indic digits in the Persian (
) locale.

As an example:


In other words what is the difference between

can anyone please explain it with simple words and simple example stating the difference ?

Answer Source

printf format option I is a glibC extension to select a locale representation for numbers. It is not defined by the C Standard and should not be used in portable code.

If the locale is properly selected and supported by your C library, calling printf("%Id", 1); might produce a string encoding the Unicode code point U+0661 ١ that is the representation of the digit one in arabic.

See http://www.fileformat.info/info/unicode/char/0661/index.htm

Conversely, printf("%d", 1); always prints 1, the western representation of number one.

To make matters even more confusing, 1 is called an arabic numeral, as opposed to roman numeral I... unrelated to the I in %Id.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download