Given a set of words, I need to put them in an hash keyed on the first letter of the word. I have words = {}, with keys A..Z and 0 for numbers and symbols. I was doing something like
var firstLetter = name.charAt(0);
firstLetter = firstLetter.toUpperCase();
if (firstLetter < "A" || firstLetter > "Z") {
firstLetter = "0";
}
if (words[firstLetter] === undefined) {
words[firstLetter] = [];
}
words[firstLetter].push(name);
but this fails with dieresis and other chars, like in the word Ärzteversorgung. That word is put in the "0" array, how could I put it in the "A" array?