gpt4 book ai didi

php - MB_CASE_*_SIMPLE 常量的用途是什么?

转载 作者:行者123 更新时间:2023-12-03 01:02:45 26 4
gpt4 key购买 nike

根据manual ,PHP 7.3 中添加了以下常量:

  • MB_CASE_FOLD
  • MB_CASE_LOWER_SIMPLE
  • MB_CASE_UPPER_SIMPLE
  • MB_CASE_TITLE_SIMPLE
  • MB_CASE_FOLD_SIMPLE

我发现了一个example MB_CASE_FOLD 的作用:

echo mb_convert_case('ẞ', MB_CASE_FOLD, 'UTF-8'); // ss

但是,我找不到任何关于 MB_CASE_*_SIMPLE 常量用途的引用。

乍一看,对于简单的 latin1 字符,MB_CASE_LOWER_SIMPLE 的行为就像 MB_CASE_LOWER

MB_CASE_*_SIMPLEMB_CASE_* 对应项有何不同?

最佳答案

我们可以在 https://github.com/php/php-src/blob/master/ext/mbstring/php_unicode.c#L223 找到相应的 C 实现

看看 git commit message :

  • Full case folding is implemented, but case-insensitive mb_* operations continue to use simple case folding. The reason is thatfull case folding of the haystack string may change the position atwhich a match occurred. This would have to be mapped back into theposition in the original string.

  • mb_convert_case() exposes both the full and the simple case mapping / folding, where full is the default. The constants are:

    • MB_CASE_LOWER (used by mb_strtolower)
    • MB_CASE_UPPER (used by mb_strtolower)
    • MB_CASE_TITLE
    • MB_CASE_FOLD
    • MB_CASE_LOWER_SIMPLE
    • MB_CASE_UPPER_SIMPLE
    • MB_CASE_TITLE_SIMPLE
    • MB_CASE_FOLD_SIMPLE (used by case-insensitive operations)

因此,带有 _SIMPLE 后缀的常量用于 Unicode 的简单大小写折叠,而那些不带后缀的常量则用于全大小写折叠

that answers全箱折叠与简单箱折叠的差异。

关于php - MB_CASE_*_SIMPLE 常量的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58858772/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com