接缝就像 sprintf 有外来字符的问题?还是我做错了什么?看起来它在从字符串中删除像 åäö 这样的字符时有效。有必要吗?
我希望以下几行能够正确对齐以生成报告:
2011-11-27 A1823 -Ref. Leif - 12 873,00 18.98
2011-11-30 A1856 -Rättat xx - 6 594,00 19.18
我像这样使用 sprintf() :%-12s %-8s -%-10s -%20s %8.2f
使用:php-5.3.23-nts-Win32-VC9-x86
PHP 中的字符串基本上是字节数组(而不是字符)。它们本身无法使用多字节编码(例如 UTF-8)。
详情请参阅:
https://www.php.net/manual/en/language.types.string.php#language.types.string.details https://www.php.net/manual/en/language.types.string.php#language.types.string.details
PHP 中的大多数字符串函数都有多字节等效函数(使用mb_
字首)。但是sprintf
才不是。
有一个用户评论(作者为“viktor at textalk dot com”),其中包含以下内容的多字节实现sprintf
在 php.net 的函数文档页面上。它可能对你有用:
https://www.php.net/manual/en/function.sprintf.php#89020 https://www.php.net/manual/en/function.sprintf.php#89020
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)