basic authentication encodings

This should test/decode first utf-8 and fallback to latin-1 to handle all tested browsers (IE10, Firefox 24, Chrome 31, and Safari 6.0.5).

Fixes #898.