Improving filter encoding of non-Unicode strings

* Improves the filter helper's "encode" filter by checking for non-
  Unicode string types, stripping smart characters, and converting.