Module swim.codec
Package swim.codec

Class Utf8

    • Method Detail

      • sizeOf

        public static int sizeOf​(int c,
                                 UtfErrorMode errorMode)
        Returns the number of bytes in the UTF-8 encoding of the Unicode code point c, handling invalid code unit sequences according to the errorMode policy. Returns the size of the UtfErrorMode.replacementChar() for surrogates and invalid code points, if UtfErrorMode.isReplacement() is `true`; otherwise returns `0` for surrogates and invalid code points. Uses the two byte modified UTF-8 encoding of the NUL character (U+0000), if UtfErrorMode.isNonZero() is `true`.
      • sizeOf

        public static int sizeOf​(int c)
        Returns the number of bytes in the UTF-8 encoding of the Unicode code point c; returns the size of the Unicode replacement character (U+FFFD) for surrogates and invalid code points.
      • sizeOf

        public static int sizeOf​(String string,
                                 UtfErrorMode errorMode)
        Returns the number of bytes in the UTF-8 encoding the given string, handling invalid code unit sequences according to the errorMode policy.
      • sizeOf

        public static int sizeOf​(String string)
        Returns the number of bytes in the UTF-8 encoding the given string, assuming the Unicode replacement character (U+FFFD) replaces unpaired surrogates and invalid code points.
      • decodedInput

        public static Input decodedInput​(Input input)
      • decodedOutput

        public static <T> Output<T> decodedOutput​(Output<T> output,
                                                  UtfErrorMode errorMode)
        Returns a new Output that accepts UTF-8 code unit sequences, and writes decoded Unicode code points to the composed output, handling invalid code unit sequences according to the errorMode policy.
      • decodedOutput

        public static <T> Output<T> decodedOutput​(Output<T> output)
        Returns a new Output that accepts UTF-8 code unit sequences, and writes decoded Unicode code points to the composed output, handling invalid code unit sequences according to the UtfErrorMode.fatal() policy.
      • decodedString

        public static Output<String> decodedString()
        Returns a new Output that accepts UTF-8 code unit sequences, and writes decoded Unicode code points to a growable String, handling invalid code unit sequences according to the UtfErrorMode.fatal() policy. The returned Output accepts an unbounded number of UTF-8 code units, remaining permanently in the cont state, and binds a String containing all decoded code points.
      • encodedOutput

        public static <T> Output<T> encodedOutput​(Output<T> output)
      • stringParser

        public static Parser<String> stringParser()
      • stringWriter

        public static <I,​O> Writer<I,​O> stringWriter​(O input,
                                                                 UtfErrorMode errorMode)
      • stringWriter

        public static <I,​O> Writer<I,​O> stringWriter​(O input)
      • writeString

        public static <O> Writer<?,​O> writeString​(O input,
                                                        Output<?> output)
      • outputDecoder

        public static <O> Decoder<O> outputDecoder​(Output<O> output,
                                                   UtfErrorMode errorMode)
        Returns a new Decoder that writes decoded Unicode code points to the given output, handling invalid code unit sequences according to the errorMode policy.
      • outputDecoder

        public static <O> Decoder<O> outputDecoder​(Output<O> output)
        Returns a new Decoder that writes decoded Unicode code points to the given output, handling invalid code unit sequences according to the UtfErrorMode.fatal() policy.
      • decodeOutput

        public static <O> Decoder<O> decodeOutput​(Output<O> output,
                                                  InputBuffer input,
                                                  UtfErrorMode errorMode)
        Writes the decoded Unicode code points of the input buffer to the given output, returning a Decoder continuation that knows how to decode subsequent input buffers. Handles invalid code unit sequences according to the errorMode policy.
      • decodeOutput

        public static <O> Decoder<O> decodeOutput​(Output<O> output,
                                                  Input input)
        Writes the decoded Unicode code points of the input buffer to the given output, returning a Decoder continuation that knows how to decode subsequent input buffers. Handles invalid code unit sequences according to the UtfErrorMode.fatal() policy.
      • decodedParser

        public static <O> Parser<O> decodedParser​(Parser<O> parser)
      • parseDecoded

        public static <O> Parser<O> parseDecoded​(Parser<O> parser,
                                                 Input input)
      • encodedWriter

        public static <I,​O> Writer<I,​O> encodedWriter​(Writer<I,​O> writer,
                                                                  UtfErrorMode errorMode)
      • encodedWriter

        public static <I,​O> Writer<I,​O> encodedWriter​(Writer<I,​O> writer)
      • writeEncoded

        public static <I,​O> Writer<I,​O> writeEncoded​(Writer<I,​O> writer,
                                                                 Output<?> output)