str_replace和utf8_decode是否需要每个值?

I am exporting orders from php to csv that are stored in CP1252 west encoding. There are a bunch of French accent characters that are causing issues in the csv.

I found that for the csv to work I have to us both str_replace and utf8_decode on every value I am echoing just to be sure so I run through the loop and have to do this to each value:

echo utf8_decode(str_replace( array( '.', ',' ), '', $row['billing_name'] )) . ","; //Addr1

The str_replace is to ensure the csv works normally with no , causing issues with the cells and the utf8_decode is to ensure the characters are converted (i think it is converting them ok not 100% sure though).

Is there a better way than having to use both functions each time I want to print a line?

Just do it in your SELECT query, convert to binary then cast it to utf8...

SELECT CONVERT(BINARY CONVERT(column_name USING latin1) USING utf8) AS converted_column FROM table