Answers.Body: <p>I would use a combination of things:</p>
  
  <ul>
  <li>Twig's <a href="https://twig.symfony.com/doc/2.x/filters/replace.html" rel="nofollow noreferrer">replace</a> filter to convert <code>ä</code> to <code>ae</code> etc.</li>
  <li>Twig's <a href="https://twig.symfony.com/doc/2.x/filters/convert_encoding.html" rel="nofollow noreferrer">convert_encoding</a> filter to eliminate any remaining non-ascii characters</li>
  <li>Craft's <a href="https://craftcms.com/docs/templating/filters#kebab" rel="nofollow noreferrer">kebab</a> filter to do its thing</li>
  </ul>
  
  <p>and of course wrap the thing up in a macro</p>
  
  <pre><code>{% macro ascii_kebab(s) %}
    {{ s
      | replace({
          'ä': 'ae'
        })
      | convert_encoding('ASCII', 'UTF-8')
      | kebab
    }}
  {% endmacro %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-10T14:02:53.833Z
Answers.Text: Thanks a lot for this! BTW: in craft 3 macros cannot contain dashes.
Answers.UserDisplayName: outline4
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-11T11:02:48.653Z
Answers.Text: @outline4 whoops! removed the dash.
Answers.UserDisplayName: Marion Newlevant
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-10-10T12:14:42.637Z
Answers.LastActivityDate: 2018-11-11T11:02:08.567Z
Answers.LastEditDate: 2018-11-11T11:02:08.567Z
Answers.UserDisplayName: Marion Newlevant
Answers.Body: <p>You can use Craft's <code>|ascii</code> Twig Filter, <a href="https://github.com/craftcms/cms/blob/master/CHANGELOG-v3.md#3125---2019-04-30" rel="nofollow noreferrer">which was added in Craft 3.1.25</a>, for this:</p>
  
  <pre><code>{{ entry.title|ascii }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-02T09:15:24.363Z
Answers.LastActivityDate: 2019-05-08T09:13:54.117Z
Answers.LastEditDate: 2019-05-08T09:13:54.117Z
Answers.UserDisplayName: Bramus
Body: <p>Is there a twig filter to encode special characters like umlauts:
  <code>{{ entry.title | filter }}</code></p>
  
  <blockquote>
    <p>Datensätze &amp; Karten</p>
  </blockquote>
  
  <p>Which then should result in:</p>
  
  <blockquote>
    <p>datensaetze-karten</p>
  </blockquote>
  
  <p>Basically what <code>'convertFilenamesToAscii' =&gt; true,</code> <a href="https://craftcms.com/docs/config-settings#convertFilenamesToAscii" rel="nofollow noreferrer">does</a> but as a filter.</p>
  
  <p>I want to use this as a anchorlink later on so umlauts are not the best to have in anchor links.</p>
  
Tags: <filter><escaping>
Title: Convert characters to Ascii
ThreadText: # Convert characters to Ascii
  
  (Asked by: username_0 on 2017-10-10)
  
  Is there a twig filter to encode special characters like umlauts:
  `{{ entry.title | filter }}`
  
  > Datensätze & Karten
  
  Which then should result in:
  
  > datensaetze-karten
  
  Basically what `'convertFilenamesToAscii' => true,` [does](https://craftcms.com/docs/config-settings#convertFilenamesToAscii) but as a filter.
  
  I want to use this as a anchorlink later on so umlauts are not the best to have in anchor links.
  
  **Tags:** filter, escaping
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-10-10. Score: 3 | Accepted answer
  
  I would use a combination of things:
  
  * Twig's [replace](https://twig.symfony.com/doc/2.x/filters/replace.html) filter to convert `ä` to `ae` etc.
  * Twig's [convert\_encoding](https://twig.symfony.com/doc/2.x/filters/convert_encoding.html) filter to eliminate any remaining non-ascii characters
  * Craft's [kebab](https://craftcms.com/docs/templating/filters#kebab) filter to do its thing
  
  and of course wrap the thing up in a macro
  
  ```
  {% macro ascii_kebab(s) %}
    {{ s
      | replace({
          'ä': 'ae'
        })
      | convert_encoding('ASCII', 'UTF-8')
      | kebab
    }}
  {% endmacro %}
  
  ```
  
  > **Comments:**
  > **username_2**: Thanks a lot for this! BTW: in craft 3 macros cannot contain dashes.  
  > **username_1**: @username_2 whoops! removed the dash.  
  
  ---
  
  ### Answer by username_3 on 2019-05-02. Score: 1
  
  You can use Craft's `|ascii` Twig Filter, [which was added in Craft 3.1.25](https://github.com/craftcms/cms/blob/master/CHANGELOG-v3.md#3125---2019-04-30), for this:
  
  ```
  {{ entry.title|ascii }}
  
  ```
  
  
  ---
  
  