using twig | replace filter in a view I'm using textbox replace in a view for an ICAL and I need to get the special characters to render. Right now calendars like Google Calendar just shows the encoded characters instead of the decoded characters. I want ' instead of this &#039; .

right now it's not doing anything. I've tried multiple ways to pull this off using  |render or using replace | but nothing works. It still just shows up with the encoded characters. example below

{% set special_1 = '&amp;#039;' %}
{% set result_1 = "'" %}
{% set special_2 = '&amp;amp;' %}
{% set result_2 = '&amp;' %}

{{ title_1|replace({ (special_1): result_1, (special_2): result_2 }) }} - {{ field_sport|replace({ (special_1): result_1, (special_2): result_2 }) }}
You can write try custom Twig_Extention

In yourmodule create service 

yourmodule.service.yml

services:
  custom_replace:
    class: Drupal\yourmodule\TwigExtension\Custom_Replace
    arguments: ['@renderer']
    tags:
      - { name: twig.extension }


src/TwigExtension/Custom_Replace.php

&lt;?php

namespace Drupal\yourmodule\TwigExtension;

/**
 * Class Custom_Replace.
 */
class Custom_Replace extends \Twig_Extension {


  /**
   * {@inheritdoc}
   */
  public function getName() {
    return 'custom_replace';
  }

  public function getFunctions() {
    return [
      new \Twig_SimpleFunction(
        'custom_replace',
        [$this, 'custom_replace'],
        ['is_safe' =&gt; ['html']]
      ),
    ];
  }



  /**
   * {@inheritdoc}
   * @param $search can a array [`word1`,`work2`] or string `word`
   */
  public function custom_replace($string, $search, $replace = '') {
    return str_ireplace($search, $replace, $string);
  }
}


In template yourpage.html.twig

{{ custom_replace('word','',string) }}