コード例 #1
0
        /// <summary>
        /// Writes a pokemon-encoded string to binary and
        /// increases the offset by the length of string.
        /// </summary>
        /// <param name="text"></param>
        public void WriteText(string text)
        {
            byte[] bytes  = Poketext.Encode(text);
            int    length = bytes.Length;

            for (int i = 0; i < length; i++)
            {
                binary[offset + i] = bytes[i];
            }
            ;

            this.offset += (uint)(length);
        }
コード例 #2
0
        /// <summary>
        /// Reads a pokemon-encoded string. First
        /// reads bytes until byte 0xFF is hit and
        /// then starting conversion to a string.
        /// </summary>
        /// <returns></returns>
        public string ReadText()
        {
            var bytes = new List <byte>();

            for (; ;)
            {
                byte b = binary[offset];
                if (b == 0xFF)
                {
                    break;
                }
                else
                {
                    bytes.Add(b);
                }
                offset += 1;
            }
            ;

            return(Poketext.Decode(bytes.ToArray()));
        }