PDA

View Full Version : Screwy string variable contents tool tips



Focus
24-Jan-2020, 07:26 AM
As well as the locals window problem with UChar arrays the tool tip that show when you hover over a local string variable that contains OEM string data show "Chinese" characters that change each time you move away and move back over the variable

I suspect characters between 128 - 159 are a problem as these are control characters in UTF8

Harm Wibier
24-Jan-2020, 07:44 AM
Being lazy here.. ;) Do you happen to have a code snippet that I can copy past and reproduce the issue?

Harm

Focus
24-Jan-2020, 08:19 AM
It's quite difficult to as I think it depends on what else is in memory as to the exact effect but this currently shows nothing in the string



Use Windows.pkg


Procedure Test
String s
Direct_Input "andrew.txt"
Readln s
Close_Input
Send None
End_Procedure


Send Test

Image shows what is in the file

13427


Perhaps try something similar in a larger application and hopefully you will get "Chinese" characters etc due to it underwriting a buffer or something

I tried using this instead but this produced "Andrw" in the locals window and tooltip which I guess is what I was looking for (although not 100% sure, but it shouldn't be as 'wonky' as it is now with a different tool tip with each hover ;))


Move ("Andr"+Character(130)+"w") to s

Focus
24-Jan-2020, 08:31 AM
Note whilst I have given an example of a file what I think I am really saying is if characters between 128-159 get into a string via a file or a COM call say or some other non "DF code" method then they cause a problem, probably wider than tooltips and the debugger locals/watch etc windows

Focus
24-Jan-2020, 08:38 AM
Actually this shows the tool tip problem much better, even the multiple hover overs and locals window problem with UChar and strings with certain chars



Use Windows.pkg


Procedure Test
UChar[] uc
String s
Move 65 to uc[0]
Move 110 to uc[1]
Move 100 to uc[2]
Move 114 to uc[3]
Move 130 to uc[4]
Move 119 to uc[5]
Move (UCharArrayToString(uc)) to s
Send None
End_Procedure


Send Test

Focus
24-Jan-2020, 08:41 AM
Actually you can get different result every time you run it from cold which would suggest a memory/pointer issue ?

Focus
12-Jun-2020, 04:59 AM
This seems to be working better in A2

The debugger display of UChar array shows ? for chars > 128 as do the tool tips if it is moved to a string

However one quirk is if I move character() instead of uchar[] to a string you don't get the ?

So these don't give the same result in the debugger. Would you expect them to ?



String s x

Move 65 to uc[0]
Move 141 to uc[1]
Move 66 to uc[2]
Move (UCharArrayToString(uc)) to s

Move (Character(65)+Character(141)+Character(66)) to x

Harm Wibier
12-Jun-2020, 06:21 AM
No, I would not expect these to give the same result. The Character function now interprets its parameter as a unicode character identifier and will return the UTF-8 representation of that character (which actually would be 2 bytes for 141: https://unicode-table.com/en/008D/). UCharArrayToString just puts the bytes in that array behind each other which in your example will likely not end up being a valid UTF-8 string.

Focus
12-Jun-2020, 07:45 AM
Thanks Harm

I just wanted to clarify as I suspect many people have code like this