Search code examples
phpms-wordtinybutstrongopentbs

OpenTBS and Special Characters (PHP)


I'm using OpenTBS to modify word templates from PHP. Basically I need to update strings in a word document from values that I have in a MySQL database. It is working well, however when I have special characters such as é, à, ô, it outputs a sequence of weird caracters.

For example the é gives me é.

Anybody knows how to fix that?

Thanks


Solution

  • By default, OpenTBS assumes that the data to be merged are Ascii encoded. It the data is UTF-8 encoded, then you have to specify it when loading the template.

    Example:

    $TBS->LoadTemplate('document.docx', OPENTBS_ALREADY_UTF8);
    

    You also have to check that your PHP script is UTF-8 encoded.

    More details are given in the manual.