Login

Tag "ascii"

Snippet List

Convert Unicode to ASCII

Unicode is great, but there are places where the conversion ends up with unintelligible characters. I first noticed this with curly quotes entered in forms on our site. `unicode_to_ascii` converts compound characters to close approximations in ASCII: such as umlaut-u to u, 1/2 (fraction glyph) to 1/2. You can add additional mappings in CHAR_REPLACEMENTS.

  • unicode
  • ascii
  • convert
Read More

htmlentities

The built-in escape filter only works with certain characters. It works great in environments where you can declare your charset (UTF-8). However, not everything can handle anything outside of the ASCII charset. This replaces all non-ASCII characters with their encoded value as `®` for ®, for example.

  • escape
  • htmlentities
  • ascii
Read More

2 snippets posted so far.