mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-21 06:39:17 +02:00
Merge branch 'fix-data-to-c-line-endings' into 'master'
data-to-c.py: autodetect line endings Closes #2340 See merge request GNOME/glib!1974
This commit is contained in:
commit
bdea78295c
@ -1,12 +1,13 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if len(sys.argv) < 4:
|
if len(sys.argv) < 4:
|
||||||
print("Usage: {0} <filename> <variable> <output>")
|
print("Usage: {0} <filename> <variable> <output>")
|
||||||
|
|
||||||
with open(sys.argv[1], "rb") as f:
|
with open(sys.argv[1], "r", encoding="utf-8", errors="backslashreplace") as f:
|
||||||
in_data = f.read().decode("utf-8", "backslashreplace")
|
in_data = f.read()
|
||||||
|
|
||||||
b = [r"\x{:02x}".format(ord(c)) for c in in_data]
|
b = [r"\x{:02x}".format(ord(c)) for c in in_data]
|
||||||
|
|
||||||
out_data = 'const char {0}[] = "'.format(sys.argv[2])
|
out_data = 'const char {0}[] = "'.format(sys.argv[2])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user