Hello,
I had some problems reading strings with special characters from a s7-300 PLC using the method GetStringAt from Sharp7 library
I changed the encoding from UTF8 to UTF7 and the conversion worked fine for me, find my code below:
Sharp7.S7 Class :
public static string GetStringAt(byte[] Buffer, int Pos) { int size = (int)Buffer[Pos + 1]; return Encoding.UTF7.GetString(Buffer, Pos + 2, size); }
Should you have any question please do not hesitate to contact me.
Best Regards, Rafael Rocha Fernandes
PLC strings are UTF8, you should read an array of byte if there are ctrl chars inside
Log in to post a comment.
Hello,
I had some problems reading strings with special characters from a s7-300 PLC using the method GetStringAt from Sharp7 library
I changed the encoding from UTF8 to UTF7 and the conversion worked fine for me, find my code below:
Sharp7.S7 Class :
Should you have any question please do not hesitate to contact me.
Best Regards,
Rafael Rocha Fernandes
Last edit: Rafael Rocha Fernandes 2016-11-28
PLC strings are UTF8, you should read an array of byte if there are ctrl chars inside