Output from preprocess_views_view_field in Drupal 8 I tried to alter the Output of an View-field with function in Drupal 8:

function mytheme_preprocess_views_view_field(&amp;$variables) {
  $view = $variables['view'];

  if ($view-&gt;storage-&gt;id() == 'myview' &amp;&amp; $variables['field']-&gt;realField == 'field_sterne_value') {

    $string = "";
    $sterne = intval($variables['field']-&gt;getValue($variables['row']));

    for ($i=1;$i &lt; $sterne;$i++){
      $string .= "&lt;img src='/themes/mytheme/img/stern.png'&gt;";
    }

    $variables['mystar'] = $string;
  }
}


The output should show the stars as Images, but shows the html-Code in Frontend.
I tried different encoding with htmlentities and html_entity_decode.
But it does not work or I did encoding in a false way.

In my custom twig-template I use {{mystar}}.
But the same problem exists when I use the original template with {{output}}.

Where is my error?
Use the raw twig filter - so, in your template:

{{ mystars|raw }}