Recently, I reformat our email template and ran into an issue wherein the middle part of the email body is re-populating at the end of the body resulting in duplicate content. The email template was created using Handlebars. My suspect is the character encoding of the production mysql database. But what ever I do (copy the prod DB locally with same encoding, etc), I could not replicate it in my local machine.
Removing the non-printable characters before rendering the content with template fixed it. Here's how I did it.
$cleaned_text = preg_replace('/[\x00-\x1F\x80-\xFF]/', ' ', $text_with_non_printable_chars);
/[\x00-\x1F\x80-\xFF]/ are characters from 0-31, 128-255 in ASCII character code.
0 comments:
Post a Comment