Javascript detect encoding of string