예제 #1
0
        /// <summary>
        /// Gets the bytes for a Generation specific string according to the input parameters.
        /// </summary>
        /// <param name="value">Decoded string.</param>
        /// <param name="generation">Generation string format</param>
        /// <param name="jp">Encoding is Japanese</param>
        /// <param name="bigendian">Encoding is BigEndian</param>
        /// <param name="maxLength"></param>
        /// <param name="language"></param>
        /// <param name="padTo">Pad to given length</param>
        /// <param name="padWith">Pad with value</param>
        /// <returns>Encoded data.</returns>
        public static byte[] SetString(string value, int generation, bool jp, bool bigendian, int maxLength, int language = 0, int padTo = 0, ushort padWith = 0)
        {
            if (bigendian)
            {
                return(generation == 3 ? StringConverter3.SetBEString3(value, maxLength, padTo, padWith) : StringConverter4.SetBEString4(value, maxLength, padTo, padWith));
            }

            switch (generation)
            {
            case 1:
            case 2: return(StringConverter12.SetString1(value, maxLength, jp, padTo, padWith));

            case 3: return(StringConverter3.SetString3(value, maxLength, jp, padTo, padWith));

            case 4: return(StringConverter4.SetString4(value, maxLength, padTo, padWith));

            case 5: return(SetString5(value, maxLength, padTo, padWith));

            case 6: return(SetString6(value, maxLength, padTo, padWith));

            default: return(SetString7(value, maxLength, language, padTo, padWith));
            }
        }
예제 #2
0
파일: PK3.cs 프로젝트: sutiam/PKHeX
 private byte[] SetString(string value, int maxLength) => StringConverter3.SetString3(value, maxLength, Japanese);