@@ -846,12 +846,11 @@ def list_directory(self, path):
846846 except UnicodeDecodeError :
847847 displaypath = urllib .parse .unquote (self .path )
848848 displaypath = html .escape (displaypath , quote = False )
849- enc = sys .getfilesystemencoding ()
850849 title = f'Directory listing for { displaypath } '
851850 r .append ('<!DOCTYPE HTML>' )
852851 r .append ('<html lang="en">' )
853852 r .append ('<head>' )
854- r .append (f '<meta charset="{ enc } ">' )
853+ r .append ('<meta charset="utf-8 ">' )
855854 r .append ('<style type="text/css">\n :root {\n color-scheme: light dark;\n }\n </style>' )
856855 r .append (f'<title>{ title } </title>\n </head>' )
857856 r .append (f'<body>\n <h1>{ title } </h1>' )
@@ -871,12 +870,12 @@ def list_directory(self, path):
871870 errors = 'surrogatepass' ),
872871 html .escape (displayname , quote = False )))
873872 r .append ('</ul>\n <hr>\n </body>\n </html>\n ' )
874- encoded = '\n ' .join (r ).encode (enc , 'surrogateescape' )
873+ encoded = '\n ' .join (r ).encode ('utf-8' , 'surrogateescape' )
875874 f = io .BytesIO ()
876875 f .write (encoded )
877876 f .seek (0 )
878877 self .send_response (HTTPStatus .OK )
879- self .send_header ("Content-type" , "text/html; charset=%s" % enc )
878+ self .send_header ("Content-type" , "text/html; charset=utf-8" )
880879 self .send_header ("Content-Length" , str (len (encoded )))
881880 self .end_headers ()
882881 return f
0 commit comments