Skip to content

Commit 49377ca

Browse files
README-Unicode.md: Fix final markdown errors, cleanup code snippet
Signed-off-by: Bernhard Kaindl <[email protected]>
1 parent 59b92e3 commit 49377ca

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

README-Unicode.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,9 @@ To fix these issues, `xcp.compat`, provides a wrapper for `open()`.
132132
It adds `encoding="utf-8", errors="replace"`
133133
to enable UTF-8 conversion and handle encoding errors:
134134

135-
```py
136-
# xcp/utf8mode.py
137-
if sys.version_info >= (3, 0):
138-
def utf8open(*args, **kwargs):
139-
if len(args) > 1 and "b" in args[1]:
140-
return open(*args, **kwargs)
141-
return open(*args, encoding="utf-8", errors="replace", **kwargs)
142-
else:
143-
utf8open = open
144-
# xcp/{cmd,pci,environ?,logger?}.py tests/test_{pci,biodevname?,...?}.py
145-
+ from .utf8mode import utf8open
146-
...
147-
- open(filename)
148-
+ utf8open(filename)
149-
```
150-
135+
```py
136+
def utf8open(*args, **kwargs):
137+
if len(args) > 1 and "b" in args[1]:
138+
return open(*args, **kwargs)
139+
return open(*args, encoding="utf-8", errors="replace", **kwargs)
140+
```

0 commit comments

Comments
 (0)