for instance name of company is "I & T"
when generating a template with name of company using function "GetInvoiceAddress", the .docx is unreadable
[$RunScript(name="GetInvoiceAddress", file="TemplatesFunctions", FieldName="NAME")]
You have to escape the output of course.
up to 11.0: escapeXml
from 11.1+: contextEncodeText
You can optionally consult this small tutorial.