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

Using non-ASCII comments lead to UnicodeDecodeError when using Symbols #275

Closed
stlehmann opened this issue Oct 19, 2021 · 0 comments
Closed

Comments

@stlehmann
Copy link
Owner

When using non-ASCII characters in comments for variables there will be a UnicodeDecodeError if symbols are used.

VAR GLOBAL
	str: STRING := 'hello';  (* Bäume *)
END_VAR
>>> plc.get_symbol("GVL.str")

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\lehmann.KUZLEIPZIG\Documents\010_src\pyads\pyads\connection.py", line 424, in get_symbol
    return AdsSymbol(self, name, index_group, index_offset, plc_datatype,
  File "C:\Users\lehmann.KUZLEIPZIG\Documents\010_src\pyads\pyads\symbol.py", line 141, in __init__
    self._create_symbol_from_info()  # Perform remote lookup
  File "C:\Users\lehmann.KUZLEIPZIG\Documents\010_src\pyads\pyads\symbol.py", line 166, in _create_symbol_from_info
    if info.comment:
  File "C:\Users\lehmann.KUZLEIPZIG\Documents\010_src\pyads\pyads\structs.py", line 348, in comment
    return self._get_string(
  File "C:\Users\lehmann.KUZLEIPZIG\Documents\010_src\pyads\pyads\structs.py", line 332, in _get_string
    return bytes(self.stringBuffer[offset:(offset + length)]) \
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 6: invalid start byte
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

No branches or pull requests

1 participant