树枝中不允许转换编码 [英] convert_encoding not allowed in twig

查看:15
本文介绍了树枝中不允许转换编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In order to convert my french html accents I try to change encoding by doing this in Twig :

{{ ddf.description | convert_encoding('UTF-8', 'HTML-ENTITIES') }}

但这是我得到的信息:

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

An exception has been thrown during the rendering of a template ("Notice: iconv(): Wrong charset, conversion from 'HTML-ENTITIES' to 'UTF-8' is not allowed").

有什么想法吗?

推荐答案

HTML-ENTITIES"不是编码.它是一种将(ISO ... UTF ...)中的特殊字符/重音编码转换为相同编码或不同编码中的等价物的功能.

"HTML-ENTITIES" is not an encoding. It is a conversion function for special characters / accented encoding in (ISO ... UTF ...) to an equivalent in the same encoding or not depending on function and language.

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

Php htmlentities function: http://php.net/manual/en/function.htmlentities.php

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

Here is the html entities table: https://www.freeformatter.com/html-entities.html

这里是 iconv 支持的编码列表:如何获取支持的编码列表php中的iconv库?

Here is the list of encoding supported by iconv: how to get list of supported encodings by iconv library in php?

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

You can try using the "| raw" twig filter or create your own.

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

这篇关于树枝中不允许转换编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆