StripWhitespace() static public method

static public StripWhitespace ( string s ) : string
s string
return string
示例#1
0
 public byte[] ToByteArray()
 {
     if (_type == ValueHandleType.Base64)
     {
         byte[] buffer = new byte[_length];
         GetBase64(buffer, 0, _length);
         return(buffer);
     }
     if (_type == ValueHandleType.UTF8 && (_length % 4) == 0)
     {
         try
         {
             int expectedLength = _length / 4 * 3;
             if (_length > 0)
             {
                 if (_bufferReader.Buffer[_offset + _length - 1] == '=')
                 {
                     expectedLength--;
                     if (_bufferReader.Buffer[_offset + _length - 2] == '=')
                     {
                         expectedLength--;
                     }
                 }
             }
             byte[] buffer       = new byte[expectedLength];
             int    actualLength = Base64Encoding.GetBytes(_bufferReader.Buffer, _offset, _length, buffer, 0);
             if (actualLength != buffer.Length)
             {
                 byte[] newBuffer = new byte[actualLength];
                 Buffer.BlockCopy(buffer, 0, newBuffer, 0, actualLength);
                 buffer = newBuffer;
             }
             return(buffer);
         }
         catch (FormatException)
         {
             // Something unhappy with the characters, fall back to the hard way
         }
     }
     try
     {
         return(Base64Encoding.GetBytes(XmlConverter.StripWhitespace(GetString())));
     }
     catch (FormatException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(exception.Message, exception.InnerException));
     }
 }
示例#2
0
 public byte[] ToByteArray()
 {
     byte[] buffer4;
     if (this.type == ValueHandleType.Base64)
     {
         byte[] buffer = new byte[this.length];
         this.GetBase64(buffer, 0, this.length);
         return(buffer);
     }
     if ((this.type == ValueHandleType.UTF8) && ((this.length % 4) == 0))
     {
         try
         {
             int num = (this.length / 4) * 3;
             if ((this.length > 0) && (this.bufferReader.Buffer[(this.offset + this.length) - 1] == 0x3d))
             {
                 num--;
                 if (this.bufferReader.Buffer[(this.offset + this.length) - 2] == 0x3d)
                 {
                     num--;
                 }
             }
             byte[] bytes = new byte[num];
             int    count = Base64Encoding.GetBytes(this.bufferReader.Buffer, this.offset, this.length, bytes, 0);
             if (count != bytes.Length)
             {
                 byte[] dst = new byte[count];
                 Buffer.BlockCopy(bytes, 0, dst, 0, count);
                 bytes = dst;
             }
             return(bytes);
         }
         catch (FormatException)
         {
         }
     }
     try
     {
         buffer4 = Base64Encoding.GetBytes(XmlConverter.StripWhitespace(this.GetString()));
     }
     catch (FormatException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(exception.Message, exception.InnerException));
     }
     return(buffer4);
 }