0

I have a function that reads some values from Siemens PLC using libnodave.dll and nodave unit but I cannot figure out the error output. I am on purpose forcing to go in error and what I get from AError := string(daveStrerror(readResult)); is an incomprehensible message:

'桴'#$2065'敤楳敲'#$2064'摡牤獥'#$2073'獩戠祥湯'#$2064'楬業⁴潦'#$2072'桴獩倠䍌'

Maybe 2064/2065/2073/2072 all represent a different error code which I have to handle independently? And why chinese? My machine is set up in Italian language.

7
  • 1
    I guess, that unit is not made for Unicode and your are using a Delphi version above D2007. Commented Feb 8, 2024 at 10:21
  • 1
    Please be aware that these values are hex values because the of $ sign! Commented Feb 8, 2024 at 11:10
  • This is just the classic issue of interpreting UTF-16 text as if it were 8 bit ANSI text. Which Delphi version are you using? Commented Feb 8, 2024 at 11:16
  • @DavidHeffernan i am using Delphi 12 Commented Feb 8, 2024 at 11:17
  • Sorry, I misspoke. It's the other way around. This is 8 bit text and you are treating it as UTF-16. Do you know what encoding this library is using? Is it ANSI or UTF-8? And are you familiar with text encodings?> Commented Feb 8, 2024 at 11:19

1 Answer 1

2

Clearly the library works with ANSI/ASCII chars. The nodave.pas unit works with PChar, which is PAnsiChar in Delphi versions up to D2007 and PWideChar above. You need to adjust the nodave.pas unit to handle that.

You might get away with replacing all PChar with PAnsiChar, but I haven't inspected it more deeply.

Sign up to request clarification or add additional context in comments.

4 Comments

Clearly??? I mean we can see it's an 8 bit encoding but we don't know more than that. Could be UTF-8.
From nodave.h: EXPORTSPEC char * DECL2 daveStrerror(int code); and S7 doesn't support UTF-8.
In addition, all available error messages are plain ASCII.
Thanks @UweRaabe i replaced all PChar with PAnsiChar and it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.