From ebea71700ff10b0624ca31647f0b4e23f6ffbc68 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Thu, 6 Jun 2024 03:11:02 +0800 Subject: [PATCH] c_client.py: Always open output files in UTF-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The UTF-8 quotes can appear in man pages etc as well, not only C code. For example, in xcb_composite_redirect_subwindows.3: xcb_composite_redirect_subwindows - Redirect all current and future children of ‘window’ Note that window is quoted by a pair of UTF-8 single quotes. Closes: #72 Signed-off-by: Xi Ruoyao Part-of: --- src/c_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/c_client.py b/src/c_client.py index b7db543..730393e 100644 --- a/src/c_client.py +++ b/src/c_client.py @@ -2660,14 +2660,14 @@ def _man_request(self, name, void, aux): name = 'man/%s.%s' % (linkname, section) if manpaths: sys.stdout.write(name) - f = open(name, 'w') + f = open(name, 'w', encoding='UTF-8') f.write('.so man%s/%s.%s' % (section, func_name, section)) f.close() if manpaths: sys.stdout.write('man/%s.%s ' % (func_name, section)) # Our CWD is src/, so this will end up in src/man/ - f = open('man/%s.%s' % (func_name, section), 'w') + f = open('man/%s.%s' % (func_name, section), 'w', encoding='UTF-8') f.write('.TH %s %s "%s" "%s" "XCB Requests"\n' % (func_name, section, center_footer, left_footer)) # Left-adjust instead of adjusting to both sides f.write('.ad l\n') @@ -3035,7 +3035,7 @@ def _man_event(self, name): if manpaths: sys.stdout.write('man/%s.%s ' % (self.c_type, section)) # Our CWD is src/, so this will end up in src/man/ - f = open('man/%s.%s' % (self.c_type, section), 'w') + f = open('man/%s.%s' % (self.c_type, section), 'w', encoding='UTF-8') f.write('.TH %s %s "%s" "%s" "XCB Events"\n' % (self.c_type, section, center_footer, left_footer)) # Left-adjust instead of adjusting to both sides f.write('.ad l\n')