【问题标题】:How To Convert Text Into Numbers如何将文本转换为数字
【发布时间】:2019-10-21 13:56:16
【问题描述】:

我想从我的 Wordpress 网站复制文本,当我使用它时,某些文本不会像包含 " 或 时那样完全复制,所以我想将文本转换为特殊代码,例如这是印地语中的文本

सुनो!! दिल ❤ धड़कने लगता है ख़यालों से ही, ना जाने क्या हाल होगा मुलाक़ातों में。

在特殊代码中就像

स ु नो !! द ि ल ❤ ध ड

ना जाने क्या हाल होगा मुलाक़ातों में

如何在 Wordpress 内容中获取此内容?

我在谷歌上搜索了很多,但一无所获

目前我在我的 Wordpress 内容中使用它

<?php
$content = get_the_content();
$newcontent = preg_replace('#<br\s*/?>#i', "\n", $content);
$result = preg_replace('#</p\s*/?>#i', "\n", $newcontent);
echo $result;

?>

【问题讨论】:

    标签: wordpress text contenteditable


    【解决方案1】:

    您可以使用PHP: bin2hex - Manual中的此函数将特殊字符转换为十六进制

    function hexentities($str) {
        $return = '';
        for($i = 0; $i < strlen($str); $i++) {
            $return .= '&#x'.bin2hex(substr($str, $i, 1)).';';
        }
        return $return;
    }
    $content = "सुनो!! दिल ❤ धड़कने लगता है ख़यालों से";
    
    echo hexentities($content);
    

    将渲染

    &#xe0;&#xa4;&#xb8;&#xe0;&#xa5;&#x81;&#xe0;&#xa4;&#xa8;&#xe0;&#xa5;&#x8b;&#x21;&#x21;&#x20;&#xe0;&#xa4;&#xa6;&#xe0;&#xa4;&#xbf;&#xe0;&#xa4;&#xb2;&#x20;&#xe2;&#x9d;&#xa4;&#x20;&#xe0;&#xa4;&#xa7;&#xe0;&#xa4;&#xa1;&#xe0;&#xa4;&#xbc;&#xe0;&#xa4;&#x95;&#xe0;&#xa4;&#xa8;&#xe0;&#xa5;&#x87;&#x20;&#xe0;&#xa4;&#xb2;&#xe0;&#xa4;&#x97;&#xe0;&#xa4;&#xa4;&#xe0;&#xa4;&#xbe;&#x20;&#xe0;&#xa4;&#xb9;&#xe0;&#xa5;&#x88;&#x20;&#xe0;&#xa4;&#x96;&#xe0;&#xa4;&#xbc;&#xe0;&#xa4;&#xaf;&#xe0;&#xa4;&#xbe;&#xe0;&#xa4;&#xb2;&#xe0;&#xa5;&#x8b;&#xe0;&#xa4;&#x82;&#x20;&#xe0;&#xa4;&#xb8;&#xe0;&#xa5;&#x87;
    

    【讨论】:

      猜你喜欢
      • 2015-05-13
      • 2016-12-03
      • 1970-01-01
      • 2021-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多