Exemple #1
0
        private void PutLabel(int recordOffset, string label)
        {
            if (Encoding.ASCII.Equals(LabelCharset))
            {
                int length = MetaDataBuffer.PutStringWithoutLengthAscii(recordOffset + LABEL_OFFSET + BitUtil.SIZE_OF_INT, label, 0, MAX_LABEL_LENGTH);
                MetaDataBuffer.PutInt(recordOffset + LABEL_OFFSET, length);
            }
            else
            {
                byte[] bytes  = LabelCharset.GetBytes(label);
                int    length = Math.Min(bytes.Length, MAX_LABEL_LENGTH);

                MetaDataBuffer.PutInt(recordOffset + LABEL_OFFSET, length);
                MetaDataBuffer.PutBytes(recordOffset + LABEL_OFFSET + BitUtil.SIZE_OF_INT, bytes, 0, length);
            }
        }
Exemple #2
0
        private void PutLabel(int recordOffset, string label)
        {
            if (Encoding.ASCII.Equals(LabelCharset))
            {
                MetaDataBuffer.PutStringAscii(recordOffset + LABEL_OFFSET, label.Length > MAX_LABEL_LENGTH ? label.Substring(0, MAX_LABEL_LENGTH) : label);
            }
            else
            {
                byte[] bytes = LabelCharset.GetBytes(label);

                if (bytes.Length > MAX_LABEL_LENGTH)
                {
                    MetaDataBuffer.PutInt(recordOffset + LABEL_OFFSET, MAX_LABEL_LENGTH);
                    MetaDataBuffer.PutBytes(recordOffset + LABEL_OFFSET + BitUtil.SIZE_OF_INT, bytes, 0, MAX_LABEL_LENGTH);
                }
                else
                {
                    MetaDataBuffer.PutInt(recordOffset + LABEL_OFFSET, bytes.Length);
                    MetaDataBuffer.PutBytes(recordOffset + LABEL_OFFSET + BitUtil.SIZE_OF_INT, bytes);
                }
            }
        }