DecodeStringStrict() public static method

Decode specified byte[] by default encoding.
/// is null. /// /// contains non-UTF-8 bits. ///
public static DecodeStringStrict ( byte value ) : string
value byte Byte[] value.
return string
Esempio n. 1
0
        private void DecodeIfNeeded()
        {
            if (this._decoded != null)
            {
                return;
            }

            if (this._encoded == null)
            {
                return;
            }

            if (this._type != BinaryType.Unknwon)
            {
                return;
            }

            try
            {
                this._decoded = MessagePackConvert.DecodeStringStrict(this._encoded);
                this._type    = BinaryType.String;
            }
            catch (DecoderFallbackException ex)
            {
                this._decodingError = ex;
                this._type          = BinaryType.Blob;
            }
        }
Esempio n. 2
0
        public void TestDecodeStringStrict_WithBom_Success()
        {
            var encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: true);

            byte[] value = encoding.GetBytes(_testValue);
            Assert.AreEqual(_testValue, MessagePackConvert.DecodeStringStrict(value));
        }
Esempio n. 3
0
 public void TestDecodeStringStrict_Empty_Empty()
 {
     Assert.That(MessagePackConvert.DecodeStringStrict(new byte[0]), Is.Empty);
 }
Esempio n. 4
0
 public void TestDecodeStringStrict_Invalid()
 {
     byte[] value = Encoding.Unicode.GetBytes(_testValue);
     Assert.Throws <DecoderFallbackException>(() => MessagePackConvert.DecodeStringStrict(value));
 }
Esempio n. 5
0
 public void TestDecodeStringStrict_Null()
 {
     Assert.Throws <ArgumentNullException>(() => MessagePackConvert.DecodeStringStrict(null));
 }