Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF and Delphi - Should I use bytes[] or string?

I have created an WCF application that will be consumed by a Delphi 7 class. AFAIK, C# string type is UTF16 and Delphi's 7 string type is Ansi.

The question is: because of C# and Delphi string types are different, should I declare all my functions with bytes[] instead of string? Am I gonna have issues by using strings on my methods?

like image 456
Rafael Colucci Avatar asked Mar 10 '26 09:03

Rafael Colucci


1 Answers

I think youll need to decalre everything WideString in Delphi.

You say you made the .NET WCF services and there to be consumed by Delphi 7 clients, but are the clients also under your control? your question seems to imply that is the case. I answer assuming that to be true.

Even if your [OperationContract]s in .NET side have byte[] type parameters all of the default contract wire serialisers (SOAP, JASON, etc...) will use the .NET XML formatting and this is (AFAK) all UTF-16.

So whilst you could put your parameters into explicit byte arrays the message payloads would all be UTF-16 XML.

like image 72
Pete Stensønes Avatar answered Mar 11 '26 21:03

Pete Stensønes