Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 388faac

Browse files
committed
#5698, part 2: generate a meta info in pydoc HTML pages indicating the encoding, and fix the -w option to use the correct encoding.
1 parent e606694 commit 388faac

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Lib/pydoc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,10 @@ class HTMLDoc(Doc):
414414

415415
def page(self, title, contents):
416416
"""Format an HTML page."""
417-
return '''
417+
return '''\
418418
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
419419
<html><head><title>Python: %s</title>
420+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
420421
</head><body bgcolor="#f0f0f8">
421422
%s
422423
</body></html>''' % (title, contents)
@@ -1510,7 +1511,7 @@ def writedoc(thing, forceload=0):
15101511
try:
15111512
object, name = resolve(thing, forceload)
15121513
page = html.page(describe(object), html.document(object, name))
1513-
file = open(name + '.html', 'w')
1514+
file = open(name + '.html', 'w', encoding='utf-8')
15141515
file.write(page)
15151516
file.close()
15161517
print('wrote', name + '.html')

0 commit comments

Comments
 (0)