Forums / Developer / Can shorten be made to shorten in unicode units rather than bytes?

Can shorten be made to shorten in unicode units rather than bytes?

Author Message

Sean Carney

Friday 06 February 2004 2:30:16 pm

We are really happy with the Shorten function and do not mind that it cuts off words. But, we do have a problem where it cuts off unicode caracters in the middle and creates a garbage character. You can see an example at our page http://nsd.hopetalk.org

We need to find a way to have shorten cut off based on unicode units.

Marco Zinn

Saturday 07 February 2004 11:46:09 am

I'm not into unicode, but splitting the unicode character should not happen.
I suggest, that you file a bug report.

Marco
http://www.hyperroad-design.com

Sean Carney

Sunday 22 February 2004 9:37:28 pm

Thank you Marco. I filed a bug report. It also seems strange that shorten is cutting off some bytes even if the characters displayed are less then then characters that have been specified.

Jan Borsodi

Wednesday 03 March 2004 7:31:59 am

PHP itself does not support Unicode internally. You can get some support with the mbstring extension and overriding internal text functions but not all of PHP will support it.

We also use the mbstring extension (if available) to perform conversion when it's needed (instead of all the time). However our i18n system does not support text operation such as extraction a portion of it yet. This means that all template operators that modify text will not work on Unicode characters.

The reason for the cutoff is the UTF8 encoding (which encodes Unicode characters), each Unicode character will be represented in an UTF8 encoding which can vary from 1 byte to 6 bytes. (1-3 is the most common).
This means that a string that has three characters can actually be 4 or more bytes, and since PHP only sees each byte as a character it will cut off at the wrong place.

The only way to get support for this is create all the various text operations that are being used in the operators and place them in the i18n library. Then change the operators to use that functionality.
However this is not a small task, especially considering problems such as case mapping (lowercase, uppercase etc.).

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

eZ debug

Timing: Jan 18 2025 22:36:10
Script start
Timing: Jan 18 2025 22:36:10
Module start 'content'
Timing: Jan 18 2025 22:36:11
Module end 'content'
Timing: Jan 18 2025 22:36:12
Script end

Main resources:

Total runtime1.5358 sec
Peak memory usage4,096.0000 KB
Database Queries199

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 589.4141180.7969
Module start 'content' 0.00751.3652 770.2109593.2031
Module end 'content' 1.37270.1631 1,363.4141337.6484
Script end 1.5358  1,701.0625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.2821210.0002
Check MTime0.00150.0978210.0001
Mysql Total
Database connection0.00110.070410.0011
Mysqli_queries1.466095.45611990.0074
Looping result0.00210.13631970.0000
Template Total1.494197.320.7471
Template load0.00250.162220.0012
Template processing1.491697.118120.7458
Template load and register function0.00020.015710.0002
states
state_id_array0.00410.265910.0041
state_identifier_array0.00300.192520.0015
Override
Cache load0.00200.1276190.0001
Sytem overhead
Fetch class attribute can translate value0.00110.071940.0003
Fetch class attribute name0.00100.062960.0002
XML
Image XML parsing0.00150.098740.0004
class_abstraction
Instantiating content class attribute0.00000.000760.0000
General
dbfile0.00200.1290340.0001
String conversion0.00000.000330.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
4content/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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/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: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs