예제 #1
0
        /// <summary>
        /// Write text to data, padding to max length with 0x00
        /// </summary>
        /// <param name="index">byte index in data to start name</param>
        /// <param name="maxLength">Max length of the text <strong>excluding</strong> the required 0x00 terminator</param>
        /// <param name="value">name to write</param>
        public void SetPaddedUtf8String(int index, int maxLength, string value)
        {
            if (value.Length > maxLength)
            {
                value = value.Substring(0, maxLength);
            }
            byte[] output;
            while (true)
            {
                //var writer = new Text.PNAWriter(value, false, true);
                //output = writer.Data;
                output = NameLoader.SaveName(value);
                if (output.Length <= maxLength)
                {
                    break;
                }
                value = value.Substring(0, value.Length - 1);
            }

            byte[] final = new byte[maxLength + 1]; // ensure padding section is overwritten and required 0x00 terminator exists.
            output.CopyTo(final, 0);

            final.CopyTo(Data, index);
        }
예제 #2
0
 public byte[] SaveName(string name)
 {
     return(NameLoader.SaveName(name));
 }