1 Reply Latest reply on Dec 11, 2013 11:34 AM by scott.steesy

    Error in TDE API C# Wrapper

    James Mills

      I am using the C# wrapper for the TDE API that was created by scott.steesy.  It looks like the wrapper doesn't insert the Type.Type_CharString into a TDE as expected.  Only the first character of the string is insert into the TDE (this is true in Scott's example).


      I am not familiar with C++.  Is there a problem with the C# wrapper or is the problem with the C++ dataextract.dll?

        • 1. Re: Error in TDE API C# Wrapper

          A CharString would only use a single byte (char) per character with a null terminator, and would be what is normally seen in C/C++. A UnicodeString uses 2 bytes (w_char) per character followed by 2 null bytes, and is less common in C/C++ but all strings in C# (Dot.Net) are in Unicode.


          If you send a Unicode string that contains a first character that is encoded such that the 2nd byte is a 0 (like ANSI encoding. most common used in the USA) into TDE using the Type.Type_CharString then it will see the 2nd byte as the null terminator and stop, giving you just a single character in the TDE content.


          So it is most fortunate that UnicodeString is supported by TDE because converting Unicode to single byte per character "strings" would have been a pain, and possibly disastrous in a localized app. So, unless you are using some very unusual code in your C#, I suspect you should be using Type.Type_UnicodeString to get the desired value into the TDE content.