예제 #1
0
        static void WriteString(IByteBufferAllocator allocator, RedisMessageType type, string content, List <object> output)
        {
            IByteBuffer buf = allocator.Buffer(type.Length + ByteBufferUtil.Utf8MaxBytes(content) +
                                               RedisConstants.EndOfLineLength);

            type.WriteTo(buf);
            ByteBufferUtil.WriteUtf8(buf, content);
            buf.WriteShort(RedisConstants.EndOfLineShort);
            output.Add(buf);
        }
예제 #2
0
        private static void CheckUtf8Bytes(string charSequence)
        {
            var buf = Unpooled.Buffer(ByteBufferUtil.Utf8MaxBytes(charSequence));

            try
            {
                int writtenBytes = ByteBufferUtil.WriteUtf8(buf, charSequence);
                int utf8Bytes    = ByteBufferUtil.Utf8Bytes(charSequence);
                Assert.Equal(writtenBytes, utf8Bytes);
            }
            finally
            {
                buf.Release();
            }
        }