aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/libghdl/__init__.py
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2022-06-21 22:13:10 +0200
committerPatrick Lehmann <Patrick.Lehmann@plc2.de>2022-12-24 09:17:28 +0100
commit5de428df07c571322cfbc055a780d41f0ce95a67 (patch)
treebaf265884019696de1b5359177970eb3bac52ee4 /pyGHDL/libghdl/__init__.py
parenta89b2986b4a252ec8ae5a5db920c2e329ad2a9a3 (diff)
downloadghdl-5de428df07c571322cfbc055a780d41f0ce95a67.tar.gz
ghdl-5de428df07c571322cfbc055a780d41f0ce95a67.tar.bz2
ghdl-5de428df07c571322cfbc055a780d41f0ce95a67.zip
Change encoding to latin-1 for libghdl (to comply with standard).
It can be monkey-patched via pyGHDL.libGHDL.ENCODING. (cherry picked from commit 2dd38de9d52493cde7c045ed73a987ed06bf617a)
Diffstat (limited to 'pyGHDL/libghdl/__init__.py')
-rw-r--r--pyGHDL/libghdl/__init__.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/pyGHDL/libghdl/__init__.py b/pyGHDL/libghdl/__init__.py
index 372f5968b..2cf9cff70 100644
--- a/pyGHDL/libghdl/__init__.py
+++ b/pyGHDL/libghdl/__init__.py
@@ -48,6 +48,8 @@ from pyGHDL import __version__ as ghdlVersion
Nullable = Optional
+ENCODING = "latin-1"
+
class LibGHDLException(GHDLBaseException):
_internalErrors: Nullable[List[str]]
@@ -164,7 +166,7 @@ def _initialize():
libghdl.libghdl__set_hooks_for_analysis()
# Set the prefix in order to locate the VHDL libraries.
- prefix = str(_libghdl_path.parent.parent).encode("utf-8")
+ prefix = str(_libghdl_path.parent.parent).encode(ENCODING)
libghdl.libghdl__set_exec_prefix(c_char_p(prefix), len(prefix))
return libghdl
@@ -197,7 +199,7 @@ def set_option(Opt: str) -> bool:
:param Opt: Option to set.
:return: Return ``True``, if the option is known and handled.
"""
- Opt = Opt.encode("utf-8")
+ Opt = Opt.encode(ENCODING)
return libghdl.libghdl__set_option(c_char_p(Opt), len(Opt)) == 0
@@ -233,7 +235,7 @@ def analyze_file(fname: str) -> Iir:
:param fname: File name
:return: Internal Intermediate Representation (IIR)
"""
- fname = fname.encode("utf-8")
+ fname = fname.encode(ENCODING)
return libghdl.libghdl__analyze_file(c_char_p(fname), len(fname))