【问题标题】:ñ to Ñ string phpñ to Ñ 字符串 php
【发布时间】:2017-02-27 07:59:32
【问题描述】:

我已经搜索过,但仍然难倒

如何将带有 ñ 的字符串转换成大写的 ñ?

例如

"Nuñez"

"NUÑEZ"

mb_strtoupper 由于没有英语而无法正常工作。

【问题讨论】:

标签: php regex


【解决方案1】:

您将需要使用编码。

$content = 'Nuñez';

mb_internal_encoding('UTF-8');
if(!mb_check_encoding($content, 'UTF-8')
OR !($content === mb_convert_encoding(mb_convert_encoding($content, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {

$content = mb_convert_encoding($content, 'UTF-8'); 
}

// NUÑEZ
echo mb_convert_case($content, MB_CASE_UPPER, "UTF-8"); 

通过PHP: mb_strtoupper not working

【讨论】:

    猜你喜欢
    • 2023-03-08
    • 2016-07-06
    • 2012-10-23
    • 2012-06-03
    • 1970-01-01
    • 2014-05-08
    • 1970-01-01
    • 2012-08-10
    • 2018-05-09
    相关资源
    最近更新 更多