PHP: RFC-2231 How to encode UTF-8 String as Content-Disposition filename

Sheep101

New Member
Scenario: (in PHP) I have a form submission with a UTF-8 encoded string (\[code\]$name\[/code\]) to support international characters. Upon submitting the form (via GET), I am creating a CSV download file. I want the name of the file to be that string + \[code\].csv\[/code\] (\[code\]"$name.csv"\[/code\]). For a western character set I can do this just fine by doing: \[code\]header("Content-Disposition: attachment; filename=\"$name\"");\[/code\]But for other character sets, the download file's name is garbage letters + \[code\].csv\[/code\] (such as \[code\]
 
Back
Top