Skip to content

Commit

Permalink
Change mbcs encoding to utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Aug 9, 2023
1 parent 630ffa3 commit 0e0db0e
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Pythonwin/pywin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
is_platform_unicode = 0

# Ditto default_platform_encoding - not referenced and will die.
default_platform_encoding = "mbcs"
default_platform_encoding = "utf-8"

# This one *is* real and used - but in practice can't be changed.
default_scintilla_encoding = "utf-8" # Scintilla _only_ supports this ATM
2 changes: 1 addition & 1 deletion Pythonwin/pywin/tools/hierlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def AddItem(self, parentHandle, item, hInsertAfter=commctrl.TVI_LAST):
if bitmapSel is None:
bitmapSel = bitmapCol
## if isinstance(text, str):
## text = text.encode("mbcs")
## text = text.encode("utf-8")
hitem = self.listControl.InsertItem(
parentHandle,
hInsertAfter,
Expand Down
2 changes: 0 additions & 2 deletions com/win32com/client/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
# literals like a quote char and backslashes makes life a little painful to
# always render the string perfectly - so just punt and fall-back to a repr()
def _makeDocString(s):
if sys.version_info < (3,):
s = s.encode("mbcs")
return repr(s)


Expand Down
4 changes: 2 additions & 2 deletions com/win32com/client/genpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ def BuildOleItemsFromType(self):

return oleItems, enumItems, recordItems, vtableItems

def open_writer(self, filename, encoding="mbcs"):
def open_writer(self, filename, encoding="utf-8"):
# A place to put code to open a file with the appropriate encoding.
# Does *not* set self.file - just opens and returns a file.
# Actually returns a handle to a temp file - finish_writer then deletes
Expand Down Expand Up @@ -1107,7 +1107,7 @@ def do_gen_file_header(self):
# We assert this is it may indicate somewhere in pywin32 that needs
# upgrading.
assert self.file.encoding, self.file
encoding = self.file.encoding # or "mbcs"
encoding = self.file.encoding

print("# -*- coding: %s -*-" % (encoding,), file=self.file)
print("# Created by makepy.py version %s" % (makepy_version,), file=self.file)
Expand Down
7 changes: 2 additions & 5 deletions com/win32com/client/makepy.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,9 @@ def main():
path = os.path.dirname(outputName)
if path != "" and not os.path.exists(path):
os.makedirs(path)
if sys.version_info > (3, 0):
f = open(outputName, "wt", encoding="mbcs")
else:
import codecs # not available in py3k.

f = codecs.open(outputName, "w", "mbcs")
f = open(outputName, "wt", encoding="utf-8")

else:
f = None

Expand Down
2 changes: 1 addition & 1 deletion isapi/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def FindWebServer(options, server_desc):
# make sure server_desc is unicode (could be mbcs if passed in
# sys.argv).
if server_desc and not isinstance(server_desc, str):
server_desc = server_desc.decode("mbcs")
server_desc = server_desc.decode("utf-8")

# get the server (if server_desc is None, the default site is acquired)
server = GetWebServer(server_desc)
Expand Down
2 changes: 1 addition & 1 deletion win32/Demos/service/pipeTestServiceClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def main():
verbose = 1
if o == "-l":
testLargeMessage(server)
msg = " ".join(args).encode("mbcs")
msg = " ".join(args).encode("utf-8")
except getopt.error as msg:
print(msg)
my_name = os.path.split(sys.argv[0])[1]
Expand Down
2 changes: 1 addition & 1 deletion win32/Demos/win32gui_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def toparam(self):
# LVM_SETITEMW etc.
val = val + "\0"
if isinstance(val, str):
val = val.encode("mbcs")
val = val.encode("utf-8")
str_buf = array.array("b", val)
vals.append(str_buf.buffer_info()[0])
vals.append(len(val))
Expand Down
2 changes: 1 addition & 1 deletion win32/Demos/winprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def run(cmd, mSec=None, stdin=None, stdout=None, stderr=None, **kw):
try:
cmd = open(cmd_name, "w+b")
out = open(out_name, "w+b")
cmd.write(cmdString.encode("mbcs"))
cmd.write(cmdString.encode("utf-8"))
cmd.seek(0)
print(
"CMD.EXE exit code:",
Expand Down

0 comments on commit 0e0db0e

Please sign in to comment.