惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
Jina AI
Jina AI
雷峰网
雷峰网
月光博客
月光博客
The GitHub Blog
The GitHub Blog
WordPress大学
WordPress大学
B
Blog RSS Feed
美团技术团队
C
CXSECURITY Database RSS Feed - CXSecurity.com
小众软件
小众软件
Security Latest
Security Latest
Microsoft Azure Blog
Microsoft Azure Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
Last Week in AI
Last Week in AI
A
Arctic Wolf
Latest news
Latest news
Attack and Defense Labs
Attack and Defense Labs
I
Intezer
F
Fortinet All Blogs
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
Help Net Security
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
V
Visual Studio Blog
P
Proofpoint News Feed
博客园 - 【当耐特】
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
Stack Overflow Blog
Stack Overflow Blog
Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
Hacker News: Ask HN
Hacker News: Ask HN
L
LINUX DO - 最新话题
H
Help Net Security
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tenable Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog

博客园 - 吾非无心

MSB4019 找不到导入的项目“C:\Users\...\AppData\Local\QtMsBuild\vs-debugtools\qt_import.props” - 吾非无心 - 博客园 类/结构最后一个成员为类(string)时可能会出现“堆损坏”(HEAP CORRUPTION DETECTED)错误 GCC在C语言中内嵌汇编 asm __volatile__ QT删除python中的单行注释 double转int QJson 存储(u)longlong有问题 QT QPixmap QImage内存泄漏 QMetaObject::connectSlotsByName: No matching signal for QT数据库连接管理类 QT多重继承带来的问题及解决办法,记录备查 QT6 源码编译Win32 x86 vc++高精度计时sleep stack smashing detected 莫名其妙的错误 strdump的问题 再加一个realloc的问题 linux下简单封装读写锁 codeblocks下libacl配置 centos8 安装、配置redis6 CentOS8让uwsgi开机自动启动django(无需登录,无需手动) libevent学习一
pyftpdlib中文乱码的解决之道
吾非无心 · 2020-09-12 · via 博客园 - 吾非无心

pyftpdlib默认用常量字符串设置了编码:utf8

这本身没有问题,但问题是windows和一些FTP client 使用的不是utf8,所以中文乱码。甚至无法进入自己建立的中文目录

解决之道:修改两个源文

为了可能再使用别的编码,所以改得略复杂点:

一、filesystem.py

       在类 AbstractedFS 中:

  增加属性:encoding

    @property
    def encoding(self):
        return self.__encoding

    @encoding.setter
    def encoding(self,value):
        self.__encoding=value

  修改__init__:

def __init__(self, root, cmd_channel,encoding):
    #...
    #...
    self.__encoding=encoding

     将本文件中所有'utf8'替换为:self.encoding

    保存修改

二、修改handler

      在类 FTPHandler 中:

     同样增加属性encoding

    @property
    def encoding(self):
        return self.__encodingg
    @encoding.setter
    def encoding(self,value):
        self.__encoding=value
        self.fs.encoding=value

    在__init__中增加:

            self.__encoding='utf8'

   在方法中 def handle_auth_success(。。。)修改一下(因为改了AbstractFS构造函数):        

          self.fs = self.abstracted_fs(home, self,self.encoding)

三、使用:

    定义好handler之后,将这赋给ftpserver前:

    handler.encoding='gbk'