Thanks for posting Adam.
Am I correct in thinking that this code kind of emulates the names mode by sorting the glyph names?
What exactally does .encoding return? When I first saw it I thought it might have been a collection of something (glyphs or glyph names) that were displayed in the window, but it doesn't appear to be that.
Oh, and related to this: I'd love to be able to select a unicode range from the encoding menu, run a script and have it set all the other fonts I have open that same view.