Mesa (main): vulkan: Open registry XML files as UTF-8

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Dec 4 20:20:17 UTC 2021


Module: Mesa
Branch: main
Commit: 6e7ffa760f31e313ccee60558310f52b28e70dc4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e7ffa760f31e313ccee60558310f52b28e70dc4

Author: Yonggang Luo <luoyonggang at gmail.com>
Date:   Thu Dec  2 23:39:20 2021 +0800

vulkan: Open registry XML files as UTF-8

"C:\CI-Tools\msys64\mingw64\bin/python3.EXE" "../../src/vulkan/util/gen_enum_to_str.py" "--xml" "../../src/vulkan/registry/vk.xml" "--outdir" "C:/work/xemu/xemu-opengl/mesa/build/windows-mingw64/src/vulkan/util"
Traceback (most recent call last):
  File "C:\work\xemu\xemu-opengl\mesa\src\vulkan\util\gen_enum_to_str.py", line 473, in <module>
    main()
  File "C:\work\xemu\xemu-opengl\mesa\src\vulkan\util\gen_enum_to_str.py", line 462, in main
    f.write(template.render(
UnicodeEncodeError: 'gbk' codec can't encode character '\xa9' in position 107: illegal multibyte sequence

Signed-off-by: Yonggang Luo <luoyonggang at gmail.com>
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14015>

---

 src/vulkan/util/gen_enum_to_str.py    | 2 +-
 src/vulkan/util/vk_entrypoints_gen.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
index 8ac8916435c..1f05aa34f93 100644
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -457,7 +457,7 @@ def main():
     for template, file_ in [(C_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.c')),
                             (H_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.h')),
                             (H_DEFINE_TEMPLATE, os.path.join(args.outdir, 'vk_enum_defines.h'))]:
-        with open(file_, 'w') as f:
+        with open(file_, 'w', encoding='utf-8') as f:
             f.write(template.render(
                 file=os.path.basename(__file__),
                 enums=enums,
diff --git a/src/vulkan/util/vk_entrypoints_gen.py b/src/vulkan/util/vk_entrypoints_gen.py
index be80dc9d184..08d4e3ae857 100644
--- a/src/vulkan/util/vk_entrypoints_gen.py
+++ b/src/vulkan/util/vk_entrypoints_gen.py
@@ -236,10 +236,10 @@ def main():
     # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
     # per entry point.
     try:
-        with open(args.out_h, 'w') as f:
+        with open(args.out_h, 'w', encoding='utf-8') as f:
             guard = os.path.basename(args.out_h).replace('.', '_').upper()
             f.write(TEMPLATE_H.render(guard=guard, **environment))
-        with open(args.out_c, 'w') as f:
+        with open(args.out_c, 'w', encoding='utf-8') as f:
             f.write(TEMPLATE_C.render(**environment))
 
     except Exception:



More information about the mesa-commit mailing list