【问题标题】:tidy_parse_string change the locale previously set with setlocaletidy_parse_string 更改先前使用 setlocale 设置的语言环境
【发布时间】:2019-08-19 15:41:54
【问题描述】:

tidy_parse_string 函数将我的语言环境更改为“C”。

<?php
setlocale(LC_ALL, 'de_DE');

/* [...] */

echo setlocale(LC_ALL, 0); // Show "de_DE"
$tidy = tidy_parse_string($text, $config, 'UTF8');
echo setlocale(LC_ALL, 0); // show "C" instead of "de_DE"
?>

有防止它的选项吗?

PHPTidy 文档中没有关于它的任何内容。


我知道我可以在使用 tidy 函数后简单地重新更改我的语言环境

<?php
setlocale(LC_ALL, 'de_DE');

/* [...] */

$oldLocale = setlocale(LC_ALL, 0);
$tidy = tidy_parse_string($text, $config, 'UTF8');
setlocale(LC_ALL, $oldLocale);
?>

但我想知道这是功能、错误还是其他原因。

谢谢

【问题讨论】:

    标签: php locale tidy


    【解决方案1】:

    这是一个错误:https://github.com/htacg/tidy-html5/issues/770

    所以解决方法是在调用之后插入 setlocale。

    <?php
    setlocale(LC_ALL, 'de_DE');
    
    /* [...] */
    
    $oldLocale = setlocale(LC_ALL, 0);
    $tidy = tidy_parse_string($text, $config, 'UTF8');
    setlocale(LC_ALL, $oldLocale);
    ?>
    

    【讨论】:

      猜你喜欢
      • 2017-06-24
      • 1970-01-01
      • 2021-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-06
      • 2011-03-24
      • 2020-04-22
      相关资源
      最近更新 更多