you are escaping it once explicitly, and converting the charset (which is not a filter marked as safe for the auto-escaper) and the auto-escaper escapes it again.

You should remove the ``e`` filter IMO (and also in the ``else`` part)