This code is incorrect in two ways:

1. It fails on non-ascii input
2. You need to preserve the canonical case for `localName`