Exemplo n.º 1
0
        public void WritePaddedStringShiftJIS(string str, int paddedRegionLength, byte?padding, bool forceTerminateAtMaxLength = false)
        {
            byte[] jis      = ShiftJISEncoding.GetBytes(str);
            int    origSize = jis.Length;

            Array.Resize(ref jis, paddedRegionLength);

            if (paddedRegionLength > origSize)
            {
                if (padding.HasValue)
                {
                    // Start at [origSize + 1] because [origSize] is the null-terminator
                    for (int i = origSize + 1; i < paddedRegionLength; i++)
                    {
                        jis[i] = padding.Value;
                    }
                }
            }
            else if (paddedRegionLength < origSize && forceTerminateAtMaxLength)
            {
                jis[jis.Length - 1] = 0;
            }

            Write(jis);
        }
Exemplo n.º 2
0
        public void WriteMtdName(string name, byte delim)
        {
            byte[] shift_jis = ShiftJISEncoding.GetBytes(name);

            Write(shift_jis.Length);

            Write(shift_jis);

            WriteDelimiter(delim);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Writes a Shift-JIS string.
        /// </summary>
        /// <param name="str">The string to write.</param>
        /// /// <param name="terminate">Whether to append a string terminator character of value 0 to the end of the written string.</param>
        public void WriteStringShiftJIS(string str, bool terminate)
        {
            byte[] b = ShiftJISEncoding.GetBytes(str);
            if (terminate)
            {
                Array.Resize(ref b, b.Length + 1);
            }

            Write(b);
        }