Forums / Developer / Charset problems in script

Charset problems in script

Author Message

Jo Henrik Endrerud

Friday 23 February 2007 5:08:45 am

I'm making an import-script on an eZp 3.8.6 installation and I'm having some problems with international characters (i.e. ÆØÅ).

Creating objects /editing in the admin interface works perfectly, and if the CLI script writes output to the screen this also works like it should. It's only when the script writes to the database, the output looks wrong in the web-interface (Norwegian characters are translated to question marks). The question marks are also stored in the database.

I am running the $script->initialize(); near the top of my script so character settings are read from the INI files as it should.

Anyone knows which setting to alter to make PHP CLI write to the database in the same way as Apache PHP does?

-Jo Henrik

Jo Henrik Endrerud | System Developer @ Seeds Consulting | http://www.seeds.no

Kristian Hole

Friday 23 February 2007 9:43:08 am

Hi Jo Henrik,

I will recommend you to implement it as a cronjob-script. Then all the settings are set up in the same way as in the modues without you having to do anything :-)

You typically need an extension with a structure like this:

extension/myimport
|-- cronjobs
|   `-- import.php
`-- settings
    `-- cronjob.ini.append.php

Where cronjob.ini is like this;

[CronjobPart-import]
Scripts[]
Scripts[]=import.php

[CronjobSettings]
ExtensionDirectories[]=myimport

and you run it like
$ php runcronjobs.php import

Otherwise, look at the textcodec updates in soap.php in the root folder.

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Arno Bouwens

Monday 08 September 2008 7:49:05 am

I had exactly the same problem as described above. The solution that worked for me was to use the php-function utf8_encode().
e.g.:

$contentObjectAttribute->setAttribute( 'data_text', utf8_encode($firstname));

instead of simply:

$contentObjectAttribute->setAttribute( 'data_text', $firstname);