[Mono-devel-list] Npgsql patch for binary types
    Jackson Harper 
    jackson at ximian.com
       
    Thu Oct 23 17:45:07 EDT 2003
    
    
  
Hello,
> This is the implementation which we already have in cvs:
> 
  I couldn't find this implementation in the mcs CVS. Is it possible
that it has not been updated yet? I did spend some time optimizing this
method this morning and got some pretty good results. Here is my
optimized version:
private static String A (Byte[] byteArray)
{
	int len = byteArray.Length;
        char[] res = new char [len * 5];
        for (int i = 0; i <len; i++) {
        	res [(i*5)] = '\\';
                res [(i*5)+1] = '\\';
                res [(i*5)+2] = (char) (((byteArray[i] & 0xC0) >> 6) +
'0');
                res [(i*5)+3] = (char) (((byteArray[i] & 0x38) >> 3) +
'0');
                res [(i*5)+4] = (char) ((byteArray[i] & 0x07) + '0');
       }
       return new String (res);
}
Here is a little test case (play with MaxSize):
http://primates.ximian.com/~jackson/f.cs
Cheers,
Jackson
    
    
More information about the Mono-devel-list
mailing list