TinyButStrong - the PHP Template Engine
Categories > OpenTBS with ODS >

Encoding problem

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Cezar
Date: 2010-07-01
Time: 18:28

Encoding problem


This time problem with encoding. I'm using UTF-8 (LANG=pl_PL.UTF-8 under Linux) and when I try to insert Polish national characters into the ODS sheet they are placed wrong. Each time they are coded as two-byte chars, but not the correct one - it looks like the are recoded somewere inside TBS...?

Of course I've played a bit with loading template with UTF charset, eg:

$TBS->LoadTemplate($template,'utf-8');

but it help not at all. What's interesting: it doesn't meter if I declare charset or not - the effect is always EXACTLY the same. Whta's funny: the polish national chars inserted directly (wwith openoffice) into the sheet when creating templete are not changed in output file  at all! Onlu thouse inserted with blockmerge.

Have you got any experience with using OpenTBS/Openoffice with national chars different then thouse from ISO-8859-1?

Thank you for your support :-)

Cezar
By: Skrol29
Date: 2010-07-02
Time: 10:04

Re: Encoding problem

Hi Cezar,

OpenTBS forces the charset to be UTF-8. In fact the Charset argument is override by OpenTBS.

Can you send to me an example of merging (template + php code) that reproduce your problem?
By: Cezar
Date: 2010-07-02
Time: 12:13

Re: Encoding problem

Example (php script + ODS file) has just been sent to you via email :-)
By: Skrol29
Date: 2010-07-02
Time: 14:55

Re: Encoding problem

Hi Cezar,

Thank you for this snipper, it help a lot for debugging.
What happens in that you data are already stored in UTF-8 (PHP and databases can saved string directly in UTF-8). Then OpenTBS convert the content a second time.

For the moment, a good workaround is to add parameter "htmlconv=no" in the fields that are not well displayed.

I'll try to find a nicer way manage UTF-8 content.
By: Cezar
Date: 2010-07-02
Time: 15:27

Re: Encoding problem

Roger that  - adding 'htmlconv=no' cures the problem :-) Anyway, it'll be nice to have more system wide sollutions ;-)

Thank you Skrol29! :-)

Cezar
By: Vincent
Date: 2012-01-20
Time: 15:39

Re: Encoding problem

Hi Skrol29,

I'm having the same problem. I can confirm that the problem is gone with 'htmlconv=no', but if I set that option, I have a problem with 'XML special chars' that corrupt the output file if they are not converted before inserting - I wrote about this not too long ago on the forums.

So I have UTF-8-encoded data, sometimes with &, < and > and plenty of ë, é etc. I have tried encoding/decoding (htmlentities,utf8_encode, etc) the data before handing the data over to TBS, but I cannot seem to get the right combination...

THX,
Vincent