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);

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:23:12
Script start
Timing: Jan 18 2025 11:23:12
Module start 'layout'
Timing: Jan 18 2025 11:23:12
Module start 'content'
Timing: Jan 18 2025 11:23:13
Module end 'content'
Timing: Jan 18 2025 11:23:13
Script end

Main resources:

Total runtime0.8179 sec
Peak memory usage4,096.0000 KB
Database Queries59

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 587.9141152.6250
Module start 'layout' 0.00540.0030 740.539139.4453
Module start 'content' 0.00840.8078 779.9844568.8359
Module end 'content' 0.81620.0017 1,348.820312.1641
Script end 0.8179  1,360.9844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.3689160.0002
Check MTime0.00130.1617160.0001
Mysql Total
Database connection0.00060.070410.0006
Mysqli_queries0.767893.8758590.0130
Looping result0.00060.0707570.0000
Template Total0.786296.120.3931
Template load0.00200.239320.0010
Template processing0.784395.888820.3921
Template load and register function0.00020.023810.0002
states
state_id_array0.00090.109810.0009
state_identifier_array0.00100.125120.0005
Override
Cache load0.00160.1996250.0001
Sytem overhead
Fetch class attribute can translate value0.00060.070630.0002
Fetch class attribute name0.00100.127740.0003
XML
Image XML parsing0.00080.102930.0003
class_abstraction
Instantiating content class attribute0.00000.001340.0000
General
dbfile0.00080.0966160.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs