Add this to the top of the file,
- Code: Select all
function unicode_to_entity(text){
var ncr_text = ""
var text_length = text.length
for(var index = 0; index < text_length; index++) {
var character = text.charAt(index)
var ncr_character = character.charCodeAt(0)
if(ncr_character < 128) {
ncr_text += character
}
else {
ncr_text += "&#"+ncr_character+";"
}
}
return ncr_text
}
And then find the line that reads
- Code: Select all
props["body"] = cleanHTML(fckEditor.GetXHTML());
And replace it with,
- Code: Select all
props["body"] = unicode_to_entity(cleanHTML(fckEditor.GetXHTML()));
PLEASE NOTE: After installing the patch be sure to clear all of your browser cache because the patch modifies JavaScript that your browser would typically cache.
Just to be clear on what this fixes and what it doesn’t:
- It's based on serializing Unicode characters as Numerical Character References to get Unicode support. It’s not Unicode as UTF-8 support, however any UTF-8 characters are converted to NCRs when writing emails and the difference between UTF-8 and NCRs are transparent to the user.
- It adds Unicode support to the body of the email in the web client (but not subject lines, or calendar events). Basically any plain-text input won’t support it but any rich-text area should.
- Athough the patch infact adds support for all Unicode characters each email client will have different capabilities at understanding NCRs. Eg, support for Thai or Sanskrit will be a bit iffy in Microsoft’s Mac Entourage, but most email clients should Just Work[tm]
- We’ve tested viewing Maori Macrons (used in a language of New Zealand) in the Zarafa web client, Evolution, Thunderbird, Microsoft’s Mac Entourage, and Outlook and they look fine.
For testing here's a ZIP of sample files with various text encodings.
I'm interested in hearing how it works for people and suggestions for improvements. Cheers,
