Improved reliability in encoding detection.

I've used "ude" for more accurate encoding detection.
For more details, please visit https://code.google.com/p/ude/