Ejemplo n.º 1
0
        internal TagTable(byte[] tagsArray)
        {
            int index = 128;//The profile header is 128 bytes in length
            int tagCount = (int)Utils.uInt32Number(index);//Byte positions 0 to 3 shall specify the number of tags contained in the tag table
            tagTbEntry = new TagTableEntry[tagCount];

            int len = index + 4 + (12 * tagCount);
            int j = 0;
            for (int i = index + 4; i < len; i += 12)
            {
                TagSignatureEnum tagSignature = (TagSignatureEnum)Utils.uInt32Number(i);//Tag signature (byte position 4 to 7)
                uint OffsetOfBegin = Utils.uInt32Number(i + 4);//Byte positions 8 to 11 (and repeating) shall specify the address of the beginning of the tag data element
                uint SizeOfTagData = Utils.uInt32Number(i + 8);
                tagTbEntry[j] = new TagTableEntry(tagSignature, OffsetOfBegin, SizeOfTagData);
                j++;
            }
        }
Ejemplo n.º 2
0
        public TextDescription(TypeSignatureEnum type, TagTableEntry profDesc)
        {
            if (type!=TypeSignatureEnum.multiLocalizedUnicode)
            {
                Text = Utils.ASCIIString((int)profDesc.OffsetOfBegin+12, (int)profDesc.SizeOfTagData - 20);
            }
            else
            {
                string curCulture = Thread.CurrentThread.CurrentCulture.Name;
                int index = (int)profDesc.OffsetOfBegin+8;//first 8 byte is type signature or reserved
                int RecordCount = (int)Utils.uInt32Number(index);//Number of records
                int RecordSize = (int)Utils.uInt32Number(index + 4);//the length in bytes of every record. The value is 12

                string[] cltInfo = new string[RecordCount];// information about what language and region the string is for
                int[] strLen = new int[RecordCount];
                int[] strOffset = new int[RecordCount];
                int end = index + 8 + RecordCount * RecordSize;
                int j = 0;
                for (int i = index + 8; i < end; i += RecordSize)
                {
                    cltInfo[j] = Utils.ASCIIString(i, 2)+"-"+Utils.ASCIIString(i + 2, 2);
                    strLen[j] = (int)Utils.uInt32Number(i + 4);
                    strOffset[j] = (int)Utils.uInt32Number(i + 8);
                    j++;
                }
                lsText = new LocaleString[RecordCount];
                for (int i = 0; i < RecordCount; i++)
                { lsText[i] = new LocaleString(cltInfo[i], index + strOffset[i] - 8, strLen[i]); }

                LocaleString ls = lsText.Where(x=>x.Locale.Name==curCulture).FirstOrDefault();
                if (ls!=null)
                {
                    Text = ls.Text;
                }
                else
                {
                    Text = lsText[0].Text;
                }
            }
        }