[Docker] [PHP] NumberFormatter :: FormatCurrency在7.4.29和7.4.28之间不兼容

发布于 2025-02-01 11:51:07 字数 1133 浏览 3 评论 0 原文

(与 https://github.com/docker.com/docker-library-library/php/php/1301/1301/1301

运行以下脚本的结果在 php之间是不同的:7.4.29-fpm-alpine php:7.4.4.28-fpm-alpine

<?php

$fmt = new \NumberFormatter('JA_JP', \NumberFormatter::CURRENCY);
$formatString = $fmt->formatCurrency(0, 'JPY');

var_dump($formatString);

结果

  • php:7.4.28-fpm-alpine(我希望)

  • php:7.4.4.29-fpm-alpine 在

(我的)问题

是否有任何方法可以在 php:7.4.4.29-fpm-alpine 中获得结果,以成为他们在 php:7.4 .28-fpm-alpine ? (有能力解决吗?)

重现的方法

参见 https://github.com /sogaoh/reproduce-compatible-format-currency (readme.md)

备注

之间也存在类似的问题

  • (未经证实)我猜想8.0.19和8.0.18
  • 8.1.6和8.1.6和8.1.5

(Same as https://github.com/docker-library/php/issues/1301 )

The results of running the following script were different between php:7.4.29-fpm-alpine and php:7.4.28-fpm-alpine.

<?php

$fmt = new \NumberFormatter('JA_JP', \NumberFormatter::CURRENCY);
$formatString = $fmt->formatCurrency(0, 'JPY');

var_dump($formatString);

Result

  • php:7.4.28-fpm-alpine (I expects)

    string(4) "¥0"
    
  • php:7.4.29-fpm-alpine

    string(3) "¥0"
    

(My) problem

Is there any way to get the results in php:7.4.29-fpm-alpine to be what they were in php:7.4.28-fpm-alpine ? (Is there a workaround?)

Way to reproduce

see https://github.com/sogaoh/reproduce-incompatibility-of-format-currency (README.md)

Remarks

( unconfirmed ) I'm guessing that there is a similar problem between

  • 8.0.19 and 8.0.18
  • 8.1.6 and 8.1.5

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷雾森÷林ヴ 2025-02-08 11:51:07

两者之间的区别在于,.28版本使用 \ uffe5 'FullWidth YEN符号,并且.29版本使用 \ u00a5 'YEN SIGN。

正如Github发行评论中指出的那样,与图像,高山或PHP本身的问题相对,可能会改变基础ICU库之间的基础ICU库。作为临时修复程序,您可以使用安装固定版本ICU的修改图像,但YMMV。

另外,您也可以在简单的替代品中使用:

str_replace("\xc2\xa5", "\xef\xbf\xa5", $formatter_output);

尽管问题本身是相当化妆的,而IMO的原始用法是货币符号的全宽字形是更可疑的选择。

The difference between the two is that the .28 version uses \uffe5 'Fullwidth Yen Sign, and the .29 version uses \u00a5 'Yen Sign.

As noted in the github issue comment, it's likely a change in the underlying ICU library between builds of the image, as opposed to an issue in the image, Alpine, or PHP themselves. As an interim fix you could use a modified image that installs a pinned version of ICU, but YMMV.

Alternatively you could shim in a simple replacement like:

str_replace("\xc2\xa5", "\xef\xbf\xa5", $formatter_output);

Though the issue itself is fairly cosmetic, and IMO the original use of a fullwidth glyph for the currency symbol was the more questionable option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文