Fix capitalization code to handle non-ASCII