Need to encode non-ascii strings since Python works with unicode strings internally, otherwise comparisons will fail.