fputcsv - outputs norwegian characters as question marks

Hi,

I have a string variable:

[php]$billing[‘street_address’] = “Præstelængen”;[/php]

It is in UTF-8:
[php]//dd(mb_detect_encoding ($billing[‘street_address’]));

// UTF-8
[/php]

I do the following to make a CSV file:

($billing is now part of $OrderData array)

[php]

		$fp = fopen($filename, 'w');

		foreach ($OrderData as $records) {
			fputcsv($fp, $records);
		}
		fclose($fp);

[/php]

The string comes out in the csv file as: Pr?stel?ngen

Googling around I saw some point to this:
[php]fputs($fp, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));[/php]

But it didn’t work for me. It gives me ? in diamonds instead.

Any ideas?

Are you using a font that has support for those characters?
Are the ? showing up in a program, or a web page?

Sponsor our Newsletter | Privacy Policy | Terms of Service