💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# `convert_encoding` New in version 1.4: The `convert_encoding` filter was added in Twig 1.4. The `convert_encoding` filter converts a string from one encoding toanother. The first argument is the expected output charset and the second oneis the input charset: <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>{{ data|convert_encoding('UTF-8', 'iso-2022-jp') }} </pre></div></td></tr></table> Note This filter relies on the [iconv](http://php.net/iconv) [http://php.net/iconv] or [mbstring](http://php.net/mbstring) [http://php.net/mbstring] extension, so one ofthem must be installed. In case both are installed, [mbstring](http://php.net/mbstring) [http://php.net/mbstring] is used bydefault (Twig before 1.8.1 uses [iconv](http://php.net/iconv) [http://php.net/iconv] by default). ### Arguments - `to`: The output charset - `from`: The input charset