예제 #1
0
 public MutagenEncodingFallbackWrapper(
     IMutagenEncoding primaryEncoding,
     IMutagenEncoding secondaryEncoding)
 {
     _primaryEncoding   = primaryEncoding;
     _secondaryEncoding = secondaryEncoding;
 }
예제 #2
0
        private static byte[] CreateNormalStrings(IReadOnlyList <string> strs, IMutagenEncoding encoding)
        {
            var ret    = new byte[100];
            var writer = new MutagenWriter(
                new BinaryWriter(new MemoryStream(ret)),
                GameConstants.SkyrimSE);

            writer.Write((uint)strs.Count);
            writer.Write((uint)strs.Sum(s => encoding.GetByteCount(s) + 1));
            int sum = 0;

            // Write index
            for (int i = 0; i < strs.Count; i++)
            {
                writer.Write(i + 1);
                writer.Write(sum);
                sum += encoding.GetByteCount(strs[i]) + 1;
            }

            // Write strings
            for (int i = 0; i < strs.Count; i++)
            {
                writer.Write(strs[i], StringBinaryType.NullTerminate, encoding);
            }

            return(ret);
        }
 /// <summary>
 /// Converts span to a string.
 /// </summary>
 /// <param name="bytes">Bytes to turn into a string</param>
 /// <param name="encoding">Encoding to use</param>
 /// <returns>string containing a character for every byte in the input span</returns>
 public static string ToZString(ReadOnlySpan <byte> bytes, IMutagenEncoding encoding)
 {
     return(encoding.GetString(bytes));
 }
예제 #4
0
 /// <summary>
 /// Interprets a subrecord's content as a string.
 /// </summary>
 /// <param name="pin">Frame to read from</param>
 /// <param name="encoding">Encoding to use</param>
 /// <returns>Subrecord's content as a string, null trimmed if applicable</returns>
 public static string AsString(this SubrecordPinFrame pin, IMutagenEncoding encoding) => pin.Frame.AsString(encoding);
예제 #5
0
 /// <summary>
 /// Interprets a subrecord's content as a string.
 /// </summary>
 /// <param name="frame">Frame to read from</param>
 /// <param name="encoding">Encoding to use</param>
 /// <returns>Subrecord's content as a string, null trimmed if applicable</returns>
 public static string AsString(this SubrecordFrame frame, IMutagenEncoding encoding)
 {
     return(BinaryStringUtility.ProcessWholeToZString(frame.Content, encoding));
 }