如何使用ftp_put和utf-8字符
I am using a custom function that creates a text file with fopen() and then this text file is uploaded on a server using ftp_put in ASCII mode.
My problem is that once the file is uploaded and once I open it in my text editor, accents are automatically transformed into gibberish characters instead of staying the same.
I know there is no FTP transfer mode for UTF-8, so what php function should I use to keep the utf-8 characters properly formatted once I open the file that has been uploaded?
fopen(..., 'w+')
original string : é
ftp_put(...., FTP_ASCII)
once the file is uploaded, the string looks like: én
Thanks
我正在使用自定义函数创建一个带有fopen()的文本文件,然后将该文本文件上传到 服务器在ASCII模式下使用ftp_put。 p>
我的问题是,一旦文件被上传,一旦我在文本编辑器中打开它,重音会自动转换为乱码而不是保持不变。 p>
我知道UTF-8没有FTP传输模式,所以当我打开上传的文件后,我应该使用什么php函数来保持utf-8字符格式正确? p>
fopen(...,'w +')
original string:é
ftp_put(....,FTP_ASCII)
once文件上传,字符串看起来像 :ñnn n代码 p>
Don't use FTP_ASCII. This mode automatically converts the line endings from the platform standard of the FTP client into the platform standard of the FTP server. Always use binary mode - this will transfer all files unchanged.
And then: How do you check the file was uploaded correctly, and how are you actually transferring the data?