“%Id”到底是什么意思? (大写 I,小写 d)
What exactly does '%Id' mean? (uppercase I, lowercase d)
我问的是 %Id
,而不是 %ld
。
谁能给我解释一下 "I" 到底是做什么的:
I
For decimal integer conversion (i
, d
, u
) 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 ("fa_IR"
) locale.
举个例子:
printf("%Id",1);
换句话说,%d
和 %Id
有什么区别?
任何人都可以用简单的文字和简单的例子来说明区别吗?
printf
格式选项 I
是对 select 数字语言环境表示的 glibC 扩展。它未由 C 标准定义,不应在可移植代码中使用。
如果语言环境被正确 selected 并被你的 C 库支持,调用 printf("%Id", 1);
可能会产生一个编码 Unicode 代码点 U+0661 ١
的字符串,即表示阿拉伯语中的数字一。
见http://www.fileformat.info/info/unicode/char/0661/index.htm
相反,printf("%d", 1);
总是打印出 1
,西方代表第一。
更令人困惑的是,1
被称为 阿拉伯数字 ,而不是 罗马数字 I
...与 %Id
中的 I
无关。
我问的是 %Id
,而不是 %ld
。
谁能给我解释一下 "I" 到底是做什么的:
I
For decimal integer conversion (i
,d
,u
) 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 ("fa_IR"
) locale.
举个例子:
printf("%Id",1);
换句话说,%d
和 %Id
有什么区别?
任何人都可以用简单的文字和简单的例子来说明区别吗?
printf
格式选项 I
是对 select 数字语言环境表示的 glibC 扩展。它未由 C 标准定义,不应在可移植代码中使用。
如果语言环境被正确 selected 并被你的 C 库支持,调用 printf("%Id", 1);
可能会产生一个编码 Unicode 代码点 U+0661 ١
的字符串,即表示阿拉伯语中的数字一。
见http://www.fileformat.info/info/unicode/char/0661/index.htm
相反,printf("%d", 1);
总是打印出 1
,西方代表第一。
更令人困惑的是,1
被称为 阿拉伯数字 ,而不是 罗马数字 I
...与 %Id
中的 I
无关。