HTML::Entities does do the encoding/decoding (and I think I will use it for a related task). However it can't help with the more general problem of determining a bi level sort decleration from a given set of sorted records.
perllocale doesn't, I think, give me a solution. The records I'm concerned with are truly international, and won't correspond to any one locale.