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

eZ debug

Timing: Jan 18 2025 10:23:21
Script start
Timing: Jan 18 2025 10:23:21
Module start 'content'
Timing: Jan 18 2025 10:23:22
Module end 'content'
Timing: Jan 18 2025 10:23:22
Script end

Main resources:

Total runtime0.8385 sec
Peak memory usage4,096.0000 KB
Database Queries196

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.8438180.8359
Module start 'content' 0.00540.7195 769.6797573.9141
Module end 'content' 0.72490.1135 1,343.5938332.7500
Script end 0.8384  1,676.3438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.4473210.0002
Check MTime0.00140.1646210.0001
Mysql Total
Database connection0.00080.091110.0008
Mysqli_queries0.760290.66041960.0039
Looping result0.00180.21261940.0000
Template Total0.813497.020.4067
Template load0.00210.246120.0010
Template processing0.811396.760620.4057
Template load and register function0.00020.025610.0002
states
state_id_array0.00080.100710.0008
state_identifier_array0.00070.088120.0004
Override
Cache load0.00180.2089250.0001
Sytem overhead
Fetch class attribute can translate value0.00150.183340.0004
Fetch class attribute name0.00140.172440.0004
XML
Image XML parsing0.01351.609740.0034
class_abstraction
Instantiating content class attribute0.00000.001240.0000
General
dbfile0.01551.8505270.0006
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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