Home Forums ActiveX components Xceed Zip for ActiveX & x64 Diferences from C# 2010 E Visual Basic 6.0 ?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #42483 |

    Why compress results from xceed zip are diferent in c# and visula basic 6?

     The byte array are diferent. Why?

     C#

            public string compactaXceedStr(ref string dados, string senha = “”)
            {
                string strRet = “”;
                object oDadoCompactado;
                object oDadoOriginal;
                byte[] bytRet;
                xcdCompressionError oXceedretorno = new xcdCompressionError();
                XceedCompression oXceed = new XceedCompression();

                oDadoOriginal = (object)dados;
                oXceed.EncryptionPassword = senha;
                oXceedretorno = oXceed.Compress(ref oDadoOriginal, out oDadoCompactado, true);

                if (oXceedretorno == xcdCompressionError.xceSuccess)
                {        
                    bytRet = (byte[])oDadoCompactado;
                    //strRet = Convert.ToBase64String(bytRet);
                    strRet = System.Text.ASCIIEncoding.Default.GetString(bytRet);
                }
                else
                    strRet = oXceed.GetErrorDescription(Convert.ToInt16(oXceedretorno));
                return strRet;
            }

     

    VB 6.0

     Public Function XCeedCompStr(ByRef varCadeia As Variant, Optional strSenha As String = “”) As String
        
        Dim xcdZip As New XceedCompression, varZip As Variant, lngRetCode As xcdCompressionError
        Dim strRet As String
            
        If strSenha <> “” Then xcdZip.EncryptionPassword = strSenha
        
        lngRetCode = xcdZip.Compress(StrConv(varCadeia, vbFromUnicode), varZip, True)
        
        If lngRetCode = xceSuccess Then
           strRet = StrConv(varZip, vbUnicode)
           XCeedCompStr = strRet
        Else
            Err.Raise lngRetCode, Err.Source & “@SPAUtil.Util.XceedCompStr”, xcdZip.GetErrorDescription(lngRetCode), Err.HelpFile, Err.HelpContext
        End If

    End Function

     

    Imported from legacy forums. Posted by Fabio (had 809 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Fabio,

    If encryption is used, the resulting compressed data will be different each time it is run because encryption always randomizes the data.

    If encryption is not used and the compressed data is different, then the developer suspects that your source data is not actually the same between C# and VB6.

    The Compress() and Uncompress() methods are meant to manipulate byte arrays. Not strings.

    From your C# code, you take a System.String object and give it to Compress() as is. Is that your intention? Or would it be better to convert the string to a byte array first?

    In VB6, you take a Variant and use StrConv().

    If you want compression to have the same results, you should make sure your input data is exactly the same in both environments. C# and VB6 might not represent strings the same way. And in the Unicode world, there are various Unicode formats. C# strings store Unicode strings as Unicode 16. VB6 might not do the same thing, etc.

     

    Imported from legacy forums. Posted by Diane [Xceed] (had 995 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.