Export csv issue with specialchars

Permalink Browser Info Environment
Hello

we have problems with some German umlauts when we export the result of a form to CSV.
I found some comments about this problem in the ResultExport.php starting at line 106.
So I tried to change from
yield utf8_encode($element->getDisplayData($value->getPostValue(), 'plain'));
to
yield htmlspecialchars($element->getDisplayData($value->getPostValue(), 'plain'));
. In our case, this has now produced clean results in the CSV export. Would this perhaps be a possibility to change this in general or am I overlooking other cases?

Best regards
Jens

Type: Discussion
Status: Archived
webpresso
View Replies:
DeWebmakers replied on at Permalink Reply
DeWebmakers
Hi Jens,

I'm not sure this also works with Arabic or Chinese characters.
Let me do a test!

Thank you for your feedback!

Best,

Corretje
DeWebmakers replied on at Permalink Reply
DeWebmakers
Hi Jens,

Did some testing...

Could you try to change the following code:
yield utf8_encode($element->getDisplayData($value->getPostValue(), 'plain'));

or
yield htmlspecialchars($element->getDisplayData($value->getPostValue(), 'plain'));

to
$string = $element->getDisplayData($value->getPostValue(), 'plain');
yield mb_convert_encoding($string, mb_detect_encoding($string), 'UTF-8');


See if the latter works!
Please let me know.

Best,

Corretje
webpresso replied on at Permalink Reply
webpresso
Hi Corretje

Your suggestion:
$string = $element->getDisplayData($value->getPostValue(), 'plain');
yield mb_convert_encoding($string, mb_detect_encoding($string), 'UTF-8');

Works very well for us with German umlauts. I have just tested it on a few forms.

Best
Jens
DeWebmakers replied on at Permalink Reply
DeWebmakers
Hi Jens,

Great! I'll add this in the next update.
Thanks for testing!

Best,

Corretje

concrete5 Environment Information

Core Version - 9.2.1
Version Installed - 9.2.1
Database Version - 20230503095900

Browser User-Agent String

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:120.0) Gecko/20100101 Firefox/120.0

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.