Support RFC6266 encoded filenames

This reapplies the commits from #1531 to master, fixing the merge conflicts and file path changes. It also implements the changes requested in #1531 and includes support for encoded language fields. Let me know if any additional changes are required.
At first glance I'm not sure what the `[1]` index contains (I had to look into the source).  Is there any chance we can unpack this out to make it clear why we are ignoring the first index?