js: If all else fails, try to extract character encoding from <meta> tags

Fixes #1993