树枝中不允许convert_encoding

Gau*_*ier 5 twig symfony-3.3

为了转换我的法语html口音,我尝试通过在Twig中执行此操作来更改编码:

{{ ddf.description | convert_encoding('UTF-8', 'HTML-ENTITIES') }}
Run Code Online (Sandbox Code Playgroud)

但这是我得到的信息:

在呈现模板期间抛出异常("通知:iconv():错误的字符集,不允许从'HTML-ENTITIES'转换为'UTF-8'").

任何的想法 ?

小智 1

“HTML-ENTITIES”不是一种编码。它是一个将 (ISO ... UTF ...) 中的特殊字符/重音编码转换为相同编码中的等效字符或不取决于功能和语言的转换函数。

PHP htmlentities 函数:http://php.net/manual/en/function.htmlentities.php

这是 html 实体表: https: //www.freeformatter.com/html-entities.html

以下是 iconv 支持的编码列表: how to get list ofsupported encodings by iconv library in php?

您可以尝试使用“| raw”树枝过滤器或创建您自己的过滤器。

Twig 中的 Unescape 或 html 解码(PHP 模板)