SceneGate / Yarhl

Framework for the implementation of format converters like game assets or media files
https://scenegate.github.io/Yarhl/
MIT License
59 stars 10 forks source link

Custom string terminators #149

Closed Kaplas80 closed 4 years ago

Kaplas80 commented 4 years ago

Description

This PR adds 3 Write methods to allow defining the string terminator token, so it can be different to \0.

public void Write(string text, string terminator, Encoding encoding = null, int maxSize = -1);
public void Write(string text, int fixedSize, string terminator, Encoding encoding = null);
public void Write(string text, Type sizeType, string terminator, Encoding encoding = null, int maxSize = -1);

Example

The usage is similar to the old methods, but defining a string parameter to use as string terminator.

writer.Write("hello", "."); // Writes "hello." on the stream using the default writer encoding.
writer.Write("hello", 4, ".", Encoding.GetEncoding("utf-8")); // Writes "hel." on the stream
writer.Write("hello", typeof(ushort), "."); // Writes the string length as a ushort and then "hello." on the stream

Linked issue: No

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version v3.1.0 :tada:

The release is available on: