bug 1124: Avoid duplicate escaping and do ordering by locale