I have a CSV string in PHP that's detected by mb_detect_encoding as UTF8. This string is written to a file. When I open it in a text editor (Programmers Notepad), the editor says it's UTF8 No Mark and when I change the encoding to ANSI, it opens correctly in Excel. I would like to write the file in ANSI so that I don't have to convert it in a text editor before I open it in Excel. Tried to use the following:
- utf8_decode($xhtml)
- iconv("UTF-8", "Windows-1252", $xhtml)
- iconv("UTF-8", "ISO-8859-1", $xhtml)
- mb_convert_encoding($xhtml, "ISO-8859-1", "UTF-8")
With utf8_decode the special characters show as question marks. iconv and mb_convert_encoding cut the strin at the first special character. Any idea on how to get this string into a file that opens in Excel?