Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UTF8 issue on systems with another default encoding #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

i0xHeX
Copy link

@i0xHeX i0xHeX commented Aug 10, 2018

Fix for issue #142

@XenoAmess
Copy link

XenoAmess commented Oct 5, 2021

Hi.

Same issue in assemble.py also.

Think it can be fixed in this pr too.

My Drive
Index: assemble.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/assemble.py b/assemble.py
--- a/assemble.py	(revision 379f37795c127820c0212929dfdab449fb06c55e)
+++ b/assemble.py	(date 1633001555741)
@@ -13,8 +13,12 @@
 
 def assembleClass(filename):
     basename = os.path.basename(filename)
-    with open(filename, 'rU') as f:
-        source = f.read()
+    try:
+        with open(filename, 'rU') as f:
+            source = f.read()
+    except Exception:
+        with open(filename, 'rU', encoding='utf8') as f:
+            source = f.read()
     return assembleSource(source, basename)
 
 if __name__== "__main__":
Index: Krakatau/script_util.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Krakatau/script_util.py b/Krakatau/script_util.py
--- a/Krakatau/script_util.py	(revision 379f37795c127820c0212929dfdab449fb06c55e)
+++ b/Krakatau/script_util.py	(date 1633001555757)
@@ -148,8 +148,12 @@
                 raise
 
         mode = 'wb' if isinstance(data, bytes) else 'w'
-        with open(out, mode) as f:
-            f.write(data)
+        try:
+            with open(out, mode) as f:
+                f.write(data)
+        except Exception:
+            with open(out, mode, encoding='utf8') as f:
+                f.write(data)
         return out
 
     def __enter__(self): return self

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants