Apache.NMS.Util.EndianBinaryReader.ReadString16 C# (CSharp) Method

ReadString16() public method

Method ReadString16, reads a String value encoded in the Java modified UTF-8 format with a length index encoded as a 16bit unsigned short.
public ReadString16 ( ) : String
return String
        public String ReadString16()
        {
            int utfLength = ReadUInt16();

            if(utfLength < 0)
            {
                return null;
            }
            else if(utfLength == 0)
            {
                return "";
            }

            return doReadString(utfLength);
        }

Usage Example

		public void testReadString16_UTF8Missing2ndByte()
		{
			// Test with bad UTF-8 encoding, missing 2nd byte of two byte value
			byte[] input = { 0x00, 0x0D, 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xC2, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6 };

			MemoryStream stream = new MemoryStream(input);
			EndianBinaryReader reader = new EndianBinaryReader(stream);

			reader.ReadString16();
		}
All Usage Examples Of Apache.NMS.Util.EndianBinaryReader::ReadString16