I have a wordpress 4.9.8 website running on PHP 7.0.22. The website uses UTF-8. I need to output the order data in ISO 8859-1 to the FTP server of our fulfillment provider. I have converted the data with utf8_decode() before writing them with fputs(). All this was working fine.
But suddenly - I believe after a wordpress update - fputs is not working any longer if the data contains German umlaut characters. E.g. if there is an 'Ä' in the data, which is encoded as 0xC4 in the string, then fputs doesn't write anything to the file so that the data are not exported.
It looks to me that in fputs or somewhere below or in the system there is a check if all characters in the string are valid characters and the function is aborted if a ISO 8859-1 character is included.
This is an excerpt from my code:
$stream = fopen( 'php://output', 'w' );
fputs( $stream, $header ); // working well
$mytext = $this->get_row_csv( $row, $headers ); // get the order data
$mytext1 = utf8_decode($mytext); // convert to ISO 8859-1
fputs( $stream, $mytext1 ); // OK with no umlaut, fails if umlaut is included
Does anybody have an idea, what has been changed in wordpress or why fputs has stopped working with these German characters and what I can do to write correctly?