2

I am working on an extension to display downloads on a website. You can view the full, current source over on GitHub.

Given this piece of code in my controller:

  $linkName = Tx_Downloads_Utility_Filename::construct( $download );
  $download->setLinkText( $linkName );

This is where I want to set the label for a download. Sadly, when it is later rendered, the result will be blank if $linkName contained an umlaut (umlauts were just my test subject, the actual scope is unknown).

For debugging purposes, I have extended that section to look like this:

  $linkName = Tx_Downloads_Utility_Filename::construct( $download );
  $download->setLinkText( $linkName );
  $this->flashMessages->add( "'" . strlen( $linkName ) . "'" );
  $this->flashMessages->add( urlencode( $linkName ) );
  $this->flashMessages->add( $linkName );

The resulting output of that is: enter image description here Please note that no third flash message is rendered.


But it's not like no umlauts would be rendered. For example, this is the record I am debugging with:

enter image description here

The link field (between the image icon and the 31.06KB) is blank but should say Text_File_Sömething.jpg. The string Sömething is rendered perfectly fine in another place of the template.

Is the problem with my Fluid template?

Oliver Salzburg
  • 21,652
  • 20
  • 93
  • 138

1 Answers1

3

Sorry, that was not really clear. Next try: you call Tx_Downloads_Utility_Filename::construct($linkName) which (by default) calls Tx_Downloads_Utility_Filename::clean($linkName) which again removes all the special characters by replacing anything that doesn't match the regex pattern /([[:alnum:]_\.-]*)/ by underscores. There seems to be a problem with encoding (maybe your db is not set to UTF-8 encoding) so Text_File_Sömething is actually turned into Text_File_Sömething and the clean() method turns that into an invalid string. try using utf8_encode() on the $filename first.

  • Awesome! I was looking in the completely wrong spot. I used [this suggestion](http://stackoverflow.com/questions/158241/php-replace-umlauts-with-closest-7-bit-ascii-equivalent-in-an-utf-8-string) to convert the filenames down now :) Thanks – Oliver Salzburg May 26 '12 at 16:24