backport r35245 and r35248
I would like to backport r35245 and r35248 in order to fix Bug #6266. The patch defaults the YAML parser encoding on unknown encodings to "ANY" encoding. Essentially guessing. I'm making the change to remain backwards compatible with files that are incorrectly opened.
I've attached the patch. Thanks!