1. <i id='RvBOn'><tr id='RvBOn'><dt id='RvBOn'><q id='RvBOn'><span id='RvBOn'><b id='RvBOn'><form id='RvBOn'><ins id='RvBOn'></ins><ul id='RvBOn'></ul><sub id='RvBOn'></sub></form><legend id='RvBOn'></legend><bdo id='RvBOn'><pre id='RvBOn'><center id='RvBOn'></center></pre></bdo></b><th id='RvBOn'></th></span></q></dt></tr></i><div id='RvBOn'><tfoot id='RvBOn'></tfoot><dl id='RvBOn'><fieldset id='RvBOn'></fieldset></dl></div>
      <bdo id='RvBOn'></bdo><ul id='RvBOn'></ul>

    1. <small id='RvBOn'></small><noframes id='RvBOn'>

    2. <tfoot id='RvBOn'></tfoot>

      <legend id='RvBOn'><style id='RvBOn'><dir id='RvBOn'><q id='RvBOn'></q></dir></style></legend>

      PHP - FTP文件名编码问题

      PHP - FTP filename encoding issue(PHP - FTP文件名编码问题)
    3. <small id='iDiy9'></small><noframes id='iDiy9'>

      <legend id='iDiy9'><style id='iDiy9'><dir id='iDiy9'><q id='iDiy9'></q></dir></style></legend>
      • <bdo id='iDiy9'></bdo><ul id='iDiy9'></ul>

              <tbody id='iDiy9'></tbody>
            <i id='iDiy9'><tr id='iDiy9'><dt id='iDiy9'><q id='iDiy9'><span id='iDiy9'><b id='iDiy9'><form id='iDiy9'><ins id='iDiy9'></ins><ul id='iDiy9'></ul><sub id='iDiy9'></sub></form><legend id='iDiy9'></legend><bdo id='iDiy9'><pre id='iDiy9'><center id='iDiy9'></center></pre></bdo></b><th id='iDiy9'></th></span></q></dt></tr></i><div id='iDiy9'><tfoot id='iDiy9'></tfoot><dl id='iDiy9'><fieldset id='iDiy9'></fieldset></dl></div>

                <tfoot id='iDiy9'></tfoot>
                本文介绍了PHP - FTP文件名编码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我会很简短.我的 FTP 函数返回错误的文件名编码

                I will be brief. My FTP function returns wrong encoding of filenames

                $conn_id = ftp_connect("site.com");
                ftp_login($conn_id, "login", "pass");
                ftp_pasv($conn_id, true);
                $buff = ftp_nlist($conn_id, "./");
                print_r($buff);
                
                ->  // result
                    array() {
                        [0]=> ".txt"
                    }
                

                文件名采用 Windows-1251 编码.

                The file name has Windows-1251 encoding.

                我尝试通过 nodejs 连接到 FTP,但它也返回了一些令人毛骨悚然的东西——ò.txt.

                I tried to connect to FTP via nodejs but it also returns something creepy — ò.txt.

                我的桌面客户端 (WinSCP) 可以正常工作.

                My desktop client (WinSCP) however works fine with this.

                PS:我尝试使用 utf8_encode - 但这也不适合我.

                PS: I tried to use utf8_encode - but that's also not working for me.

                推荐答案

                如果编码是你可以尝试使用 mb_convert_encoding.下面的代码应该输出正确的值.

                If the encoding is of you could try to change it using mb_convert_encoding. The code below should output the correct value.

                <?php
                echo mb_convert_encoding($buff[0], "UTF-8");
                //or
                echo mb_convert_encoding($buff[0], "UTF-8", "windows-1251");
                ?>
                

                如果它不起作用,您可以尝试使用类似的方法找到正确的编码

                If it doesnt work, you can try to find the right encoding using something like

                <?php
                foreach(mb_list_encodings() as $chr){
                  echo mb_convert_encoding($buff[0], 'UTF-8', $chr)." : ".$chr."<br>"; 
                } 
                ?>
                

                这篇关于PHP - FTP文件名编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <bdo id='6e6OW'></bdo><ul id='6e6OW'></ul>

                    <i id='6e6OW'><tr id='6e6OW'><dt id='6e6OW'><q id='6e6OW'><span id='6e6OW'><b id='6e6OW'><form id='6e6OW'><ins id='6e6OW'></ins><ul id='6e6OW'></ul><sub id='6e6OW'></sub></form><legend id='6e6OW'></legend><bdo id='6e6OW'><pre id='6e6OW'><center id='6e6OW'></center></pre></bdo></b><th id='6e6OW'></th></span></q></dt></tr></i><div id='6e6OW'><tfoot id='6e6OW'></tfoot><dl id='6e6OW'><fieldset id='6e6OW'></fieldset></dl></div>

                        <legend id='6e6OW'><style id='6e6OW'><dir id='6e6OW'><q id='6e6OW'></q></dir></style></legend>

                      • <small id='6e6OW'></small><noframes id='6e6OW'>

                            <tbody id='6e6OW'></tbody>
                        • <tfoot id='6e6OW'></tfoot>