当前位置: 首页>>代码示例>>C#>>正文


C# com.usesPadding方法代码示例

本文整理汇总了C#中com.usesPadding方法的典型用法代码示例。如果您正苦于以下问题:C# com.usesPadding方法的具体用法?C# com.usesPadding怎么用?C# com.usesPadding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com的用法示例。


在下文中一共展示了com.usesPadding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _readBinary

 /// <exception cref="System.IO.IOException"/>
 protected internal virtual int _readBinary(com.fasterxml.jackson.core.Base64Variant
     b64variant, Sharpen.OutputStream @out, byte[] buffer)
 {
     int outputPtr = 0;
     int outputEnd = buffer.Length - 3;
     int outputCount = 0;
     while (true)
     {
         // first, we'll skip preceding white space, if any
         int ch;
         do
         {
             if (_inputPtr >= _inputEnd)
             {
                 loadMoreGuaranteed();
             }
             ch = (int)_inputBuffer[_inputPtr++] & unchecked((int)(0xFF));
         }
         while (ch <= INT_SPACE);
         int bits = b64variant.decodeBase64Char(ch);
         if (bits < 0)
         {
             // reached the end, fair and square?
             if (ch == INT_QUOTE)
             {
                 break;
             }
             bits = _decodeBase64Escape(b64variant, ch, 0);
             if (bits < 0)
             {
                 // white space to skip
                 continue;
             }
         }
         // enough room? If not, flush
         if (outputPtr > outputEnd)
         {
             outputCount += outputPtr;
             @out.write(buffer, 0, outputPtr);
             outputPtr = 0;
         }
         int decodedData = bits;
         // then second base64 char; can't get padding yet, nor ws
         if (_inputPtr >= _inputEnd)
         {
             loadMoreGuaranteed();
         }
         ch = _inputBuffer[_inputPtr++] & unchecked((int)(0xFF));
         bits = b64variant.decodeBase64Char(ch);
         if (bits < 0)
         {
             bits = _decodeBase64Escape(b64variant, ch, 1);
         }
         decodedData = (decodedData << 6) | bits;
         // third base64 char; can be padding, but not ws
         if (_inputPtr >= _inputEnd)
         {
             loadMoreGuaranteed();
         }
         ch = _inputBuffer[_inputPtr++] & unchecked((int)(0xFF));
         bits = b64variant.decodeBase64Char(ch);
         // First branch: can get padding (-> 1 byte)
         if (bits < 0)
         {
             if (bits != com.fasterxml.jackson.core.Base64Variant.BASE64_VALUE_PADDING)
             {
                 // as per [JACKSON-631], could also just be 'missing'  padding
                 if (ch == '"' && !b64variant.usesPadding())
                 {
                     decodedData >>= 4;
                     buffer[outputPtr++] = unchecked((byte)decodedData);
                     break;
                 }
                 bits = _decodeBase64Escape(b64variant, ch, 2);
             }
             if (bits == com.fasterxml.jackson.core.Base64Variant.BASE64_VALUE_PADDING)
             {
                 // Ok, must get padding
                 if (_inputPtr >= _inputEnd)
                 {
                     loadMoreGuaranteed();
                 }
                 ch = _inputBuffer[_inputPtr++] & unchecked((int)(0xFF));
                 if (!b64variant.usesPaddingChar(ch))
                 {
                     throw reportInvalidBase64Char(b64variant, ch, 3, "expected padding character '" +
                          b64variant.getPaddingChar() + "'");
                 }
                 // Got 12 bits, only need 8, need to shift
                 decodedData >>= 4;
                 buffer[outputPtr++] = unchecked((byte)decodedData);
                 continue;
             }
         }
         // Nope, 2 or 3 bytes
         decodedData = (decodedData << 6) | bits;
         // fourth and last base64 char; can be padding, but not ws
         if (_inputPtr >= _inputEnd)
         {
//.........这里部分代码省略.........
开发者ID:davidraleigh,项目名称:jackson-parser-cs,代码行数:101,代码来源:UTF8StreamJsonParser.cs

示例2: _decodeBase64

 /*
 /**********************************************************
 /* Internal methods, binary access
 /**********************************************************
 */
 /// <summary>
 /// Efficient handling for incremental parsing of base64-encoded
 /// textual content.
 /// </summary>
 /// <exception cref="System.IO.IOException"/>
 protected internal byte[] _decodeBase64(com.fasterxml.jackson.core.Base64Variant 
     b64variant)
 {
     com.fasterxml.jackson.core.util.ByteArrayBuilder builder = _getByteArrayBuilder();
     //main_loop:
     while (true)
     {
         // first, we'll skip preceding white space, if any
         int ch;
         do
         {
             if (_inputPtr >= _inputEnd)
             {
                 loadMoreGuaranteed();
             }
             ch = (int)_inputBuffer[_inputPtr++] & unchecked((int)(0xFF));
         }
         while (ch <= INT_SPACE);
         int bits = b64variant.decodeBase64Char(ch);
         if (bits < 0)
         {
             // reached the end, fair and square?
             if (ch == INT_QUOTE)
             {
                 return builder.toByteArray();
             }
             bits = _decodeBase64Escape(b64variant, ch, 0);
             if (bits < 0)
             {
                 // white space to skip
                 continue;
             }
         }
         int decodedData = bits;
         // then second base64 char; can't get padding yet, nor ws
         if (_inputPtr >= _inputEnd)
         {
             loadMoreGuaranteed();
         }
         ch = _inputBuffer[_inputPtr++] & unchecked((int)(0xFF));
         bits = b64variant.decodeBase64Char(ch);
         if (bits < 0)
         {
             bits = _decodeBase64Escape(b64variant, ch, 1);
         }
         decodedData = (decodedData << 6) | bits;
         // third base64 char; can be padding, but not ws
         if (_inputPtr >= _inputEnd)
         {
             loadMoreGuaranteed();
         }
         ch = _inputBuffer[_inputPtr++] & unchecked((int)(0xFF));
         bits = b64variant.decodeBase64Char(ch);
         // First branch: can get padding (-> 1 byte)
         if (bits < 0)
         {
             if (bits != com.fasterxml.jackson.core.Base64Variant.BASE64_VALUE_PADDING)
             {
                 // as per [JACKSON-631], could also just be 'missing'  padding
                 if (ch == '"' && !b64variant.usesPadding())
                 {
                     decodedData >>= 4;
                     builder.append(decodedData);
                     return builder.toByteArray();
                 }
                 bits = _decodeBase64Escape(b64variant, ch, 2);
             }
             if (bits == com.fasterxml.jackson.core.Base64Variant.BASE64_VALUE_PADDING)
             {
                 // Ok, must get padding
                 if (_inputPtr >= _inputEnd)
                 {
                     loadMoreGuaranteed();
                 }
                 ch = _inputBuffer[_inputPtr++] & unchecked((int)(0xFF));
                 if (!b64variant.usesPaddingChar(ch))
                 {
                     throw reportInvalidBase64Char(b64variant, ch, 3, "expected padding character '" +
                          b64variant.getPaddingChar() + "'");
                 }
                 // Got 12 bits, only need 8, need to shift
                 decodedData >>= 4;
                 builder.append(decodedData);
                 continue;
             }
         }
         // Nope, 2 or 3 bytes
         decodedData = (decodedData << 6) | bits;
         // fourth and last base64 char; can be padding, but not ws
         if (_inputPtr >= _inputEnd)
//.........这里部分代码省略.........
开发者ID:davidraleigh,项目名称:jackson-parser-cs,代码行数:101,代码来源:UTF8StreamJsonParser.cs


注:本文中的com.usesPadding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。