[TYPO3-dev] Sorting and grouping of list - problem with rendering non-english characters

Jigal van Hemert jigal at xs4all.nl
Mon Jun 8 10:41:57 CEST 2009


Hi Erik,

> I'm working with an extension which are going to render a list in
> frontend like this.
>
> A
> A new day
> About TypoScript
>
> E
> Evalueting of CMS
>
> ans so on. Every title, text are linking to more information

This could be done with Typoscript, unless you need a paginator in the list.
But if you want to write an extension for it, fine with me :-)

> I fetch the list as an array ( and using
>
> 	$firstletter = row[field][0];
>
> to fetch the first letter of the sentence/title and place it in a
> marker.

Here you use the string as an array, which will give you only the first
byte and not (always) the first character! In encodings such as utf-8,
etc. some characters can use more than one byte (utf-8 currently 1-4 bytes
per character)

t3lib_cs::crop() or t3lib_cs::substr() seem more appropriate to me as they
are multi-byte safe.

In general: try to use TYPO3 API functions whenever possible. They are
adapted to TYPO3 specifics or they can be extended in some way.
I also hope that you build your links with one of the many typolink()-like
functions; that way you will be compatible with realurl, cooluri, etc.

Regards,
-- 
Jigal van Hemert.





More information about the TYPO3-dev mailing list