Function NullTerminated

  • @NullTerminated decorator is made to be used with the @Utf{8,16,32} decorators to read the string until a 0 is encountered. Because decoding an array of utf{8,16,32} character will drop this 0 this decorator make sure to add it again to the array when writing an utf encoded string.

    Type Parameters

    • This extends object
    • Value

    Parameters

    Returns void

    class Protocol {
    @Utf8
    @NullTerminated // Should be closer to the property than `Utf8`
    name: string

    @Until(EOF)
    @Utf16
    @NullTerminated
    name: string[] // Create an array of null terminated utf16 strings
    }

    You can't use this decorator with @Ascii decorator. Use @NullTerminatedString instead.