VO FWrite->C# ReadAllText

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

VO FWrite->C# ReadAllText

Post by ic2 »

In VO I write a crypted string like this:

ptrHandle := FCreate(cPath)
// ....some checks. creating + crypting the string
FWrite(ptrHandle, cText)


In C# I read it back as follows:

string cName = File.ReadAllText(cExeDir + "MyFile.txt", Encoding.ASCII);

(after which XSharp.VO.Functions.CryptRaw should decrypt it again, as suggested by Chris).

But the value in cName (before decrypting) doesn't look like the value I see written by the VO function.

What should I do to get the same result? In C# I tried some different encodings without success. I read the https://www.xsharp.eu/forum/public-prod ... se64#16183 thread
but I am not sure if I need to encode my string first in VO to get it back correctly in C#.

Finally I considered to use the X# function FRead but as this is part of XSharp.Core and not XSharp.VO I doubt if this is going to give me the same string back.

Dick
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

VO FWrite->C# ReadAllText

Post by ic2 »

I think I solved it in the meantime.

string cName = File.ReadAllText(cExeDir + "Myfile.txt", Encoding.GetEncoding("Windows-1252"));

This should give the same value as the encoding which was used on creating it with VO.
I need to check a couple of keys to see if CryptRaw will always give the same value, because in my first example the first character of the (user) name was replaced by a ® character using CryptRaw and it was not with the further equal VO (de-) Crypt call.

I've added a space (a couple of fields are encrypted) and now it seems fine, the space is not converted to the ®. Very strange.

Dick
Post Reply