From: dean.earley@icode.co.uk   
      
   Dean Earley wrote:   
   > J French wrote:   
   >> On Fri, 16 Feb 2007 23:09:35 +1100, "Antony Clements"   
   >> wrote:   
   >>   
   >>> correction of mistake. i am only grabbing 4 bytes of both strings   
   >>> instead of the original 8 and am trying to generate a number between   
   >>> 0 and 255255255255 from each 4 byte block of string   
   >>   
   >> You could just use CopyMemory to slap the 4 character string into a 4   
   >> byte long   
   >>   
   >> This is not reliable in Far Eastern locales which use Multi Byte   
   >> Character Sets, but with those areas the bets are off for strings.   
   >>   
   >> I gather you are doing some sort of encryption.   
   >   
   > No, you CAN'T just CopyMemory from a 4 char string to a 4 byte long (and   
   > get the results you expect.   
   > As per my previous email, strings in vb are UTF-16 Unicode, meaning that   
   > for normal ASCII text, EVERY character is followed by a single null byte.   
   >   
   > To get the ASCII value of each character in each member of a byte array   
   > (which you just proposed), you WILL need to use StrConv (unless you feel   
   > like manually copying each character)   
      
   Admittedly, I was assuming you were using the standard declaration of   
   CopyMemory that takes two pointers rather than a string which is   
   transparently converted by VB before being passed.   
      
   I still highly recommend using just StrConv for this operation.   
      
   --   
   Dean Earley (dean.earley@icode.co.uk)   
   i-Catcher Development Team   
      
   iCode Systems   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|