eZString::fromString() unsupported characters

Author Message

Fabien Scantamburlo

Tuesday 06 April 2010 6:57:28 am

Hi,

I need to import articles. So, the articles include special characters within headline. I use eZContentObjectAttribute::fromString() method to set the content of the attribute.

For example, the "£" character (headline as eZString datatype):

Without encoding:

$contentObjectAttribute->fromString ( 'My £3M headline' );

Result: "My " (truncate string, either the url_alias: My)

With html entity encoding:

$contentObjectAttribute->fromString ( 'My £3M headline' );

Result: "My £3M headline" (unwashed character, either the url_alias: My-pound-3M-headline)

With utf8 encoding:

$contentObjectAttribute->fromString( 'My £3M headline' );

Result: "My £3M headline" (unwashed character, either the url_alias: My-163-3M-headline)

Of course, it happens with all unASCII characters.

Has anyone already dealt with this ?

Best regards,

Fabien.

Ekkehard Dörre

Tuesday 06 April 2010 8:22:37 am

Hi Fabien,

I always use http://projects.ez.no/data_import which is fantastic and I really love it and I never had problems with clean UTF-8 and URLs and in german there are many Umlaute äüößÖÄÜ in headlines.

Perhaps a good idea to use a import framework?

Greetings, ekke

edited: typo

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Fabien Scantamburlo

Wednesday 07 April 2010 3:37:03 am

Hi Ekke,

Thanks for your help.

I fixed my issue. The bug wasn't due to the eZPublish framework. It was due to the transition table I used.
I have to set

mysql_query( "SET NAMES UTF8" );

before the query to get the headline...

The encoding was wrong.

mb_detect_encoding()

return nothing instead of utf8.

Hope this issue can help anyone...

Regards,

Fabien.

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