示例#1
0
        // private methods ---------------------------------------------------

        /// <summary>
        /// Reads an individual record of AlgorithmNames
        /// </summary>
        ///
        /// <returns>an instance of AlgorithNames if read is successful otherwise null</returns>
        /// <exception cref="IOException">thrown when file read error occurs or data is corrupted</exception>
        private UCharacterName.AlgorithmName ReadAlg()
        {
            UCharacterName.AlgorithmName result = new UCharacterName.AlgorithmName();
            int   rangestart = m_dataInputStream_.ReadInt();
            int   rangeend   = m_dataInputStream_.ReadInt();
            sbyte type       = m_dataInputStream_.ReadByte();
            sbyte variant    = m_dataInputStream_.ReadByte();

            if (!result.SetInfo(rangestart, rangeend, type, variant))
            {
                return(null);
            }

            int size = m_dataInputStream_.ReadChar();

            if (type == IBM.ICU.Impl.UCharacterName.AlgorithmName.TYPE_1_)
            {
                char[] factor = new char[variant];
                for (int j = 0; j < variant; j++)
                {
                    factor[j] = m_dataInputStream_.ReadChar();
                }

                result.SetFactor(factor);
                size -= (variant << 1);
            }

            StringBuilder prefix = new StringBuilder();
            char          c      = (char)(m_dataInputStream_.ReadByte() & 0x00FF);

            while (c != 0)
            {
                prefix.Append(c);
                c = (char)(m_dataInputStream_.ReadByte() & 0x00FF);
            }

            result.SetPrefix(prefix.ToString());

            size -= (ALG_INFO_SIZE_ + prefix.Length + 1);

            if (size > 0)
            {
                byte[] str0 = new byte[size];
                m_dataInputStream_.ReadFully(str0);
                result.SetFactorString(str0);
            }
            return(result);
        }
示例#2
0
        // private methods ---------------------------------------------------

        /// <summary>
        /// Reads an individual record of <see cref="UCharacterName.AlgorithmName"/>s
        /// </summary>
        /// <returns>An instance of <see cref="UCharacterName.AlgorithmName"/>s if read is successful otherwise null.</returns>
        /// <exception cref="IOException">Thrown when file read error occurs or data is corrupted.</exception>
        private UCharacterName.AlgorithmName ReadAlg()
        {
            UCharacterName.AlgorithmName result =
                new UCharacterName.AlgorithmName();
            int  rangestart = m_byteBuffer_.GetInt32();
            int  rangeend   = m_byteBuffer_.GetInt32();
            byte type       = m_byteBuffer_.Get();
            byte variant    = m_byteBuffer_.Get();

            if (!result.SetInfo(rangestart, rangeend, type, variant))
            {
                return(null);
            }

            int size = m_byteBuffer_.GetChar();

            if (type == UCharacterName.AlgorithmName.TYPE_1_)
            {
                char[] factor = ICUBinary.GetChars(m_byteBuffer_, variant, 0);

                result.SetFactor(factor);
                size -= (variant << 1);
            }

            StringBuilder prefix = new StringBuilder();
            char          c      = (char)(m_byteBuffer_.Get() & 0x00FF);

            while (c != 0)
            {
                prefix.Append(c);
                c = (char)(m_byteBuffer_.Get() & 0x00FF);
            }

            result.SetPrefix(prefix.ToString());

            size -= (ALG_INFO_SIZE_ + prefix.Length + 1);

            if (size > 0)
            {
                byte[] str = new byte[size];
                m_byteBuffer_.Get(str);
                result.SetFactorString(str);
            }
            return(result);
        }