Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use cp65001 ~ UTF-8 on windows, re #40

The Windows cmd has limited/buggy but existing unicode support.

cp65001 is supposed to be UTF-8.
It is buggy and has problems and python decided not to add it as an alias
for utf-8.
Batchfiles are buggy with cp65001, therefore this weird cmd /c change.

Since having unicode output is desirable, we alias cp65001 to utf-8,
and use os.write in printEncoded on Windows.
Using sys.stdout.write gives IOError

We also set cp65001 in isrcsubmit.bat
Please note, that isrcsubmit.bat will not start if cp65001 is set before
starting isrcsubmit.bat

If that change in the batchfile turns out to be buggy,
we should create a separate isrcsubmit-unicode.bat.
  • Loading branch information...
commit 8f931940ec9b45e2ee72db0bc19e97a9f25bf6f2 1 parent 3d45aeb
@JonnyJD authored
Showing with 15 additions and 2 deletions.
  1. +2 −1  isrcsubmit.bat
  2. +13 −1 isrcsubmit.py
View
3  isrcsubmit.bat
@@ -1,4 +1,5 @@
@echo off
-isrcsubmit.py %*
+for /f "tokens=2 delims=:." %%x in ('chcp') do set cp=%%x
+chcp 65001>NUL & cmd /c "isrcsubmit.py %*" & chcp %cp%>NUL
echo.
pause
View
14 isrcsubmit.py
@@ -32,6 +32,7 @@
import os
import re
import sys
+import codecs
import getpass
import tempfile
from datetime import datetime
@@ -300,6 +301,14 @@ def askForOffset(discTrackCount, releaseTrackCount):
if num in range(0, limit + 1):
return num
+def cp65001(name):
+ """This might be buggy, but better than just a LookupError
+ """
+ if name.lower() == "cp65001":
+ return codecs.lookup("utf-8")
+
+codecs.register(cp65001)
+
def printEncoded(*args):
"""This will replace unsuitable characters and doesn't append a newline
"""
@@ -310,7 +319,10 @@ def printEncoded(*args):
else:
stringArgs += str(arg),
msg = " ".join(stringArgs)
- sys.stdout.write(msg + " ")
+ if os.name == "nt":
+ os.write(sys.stdout.fileno(), msg + " ")
+ else:
+ sys.stdout.write(msg + " ")
def printError(*args):
stringArgs = tuple(map(str, args))
Please sign in to comment.
Something went wrong with that request. Please try again.