java.lang.Object
swim.codec.Utf8
-
Method Summary
Modifier and TypeMethodDescriptionstatic <O> Decoder<O>
decode
(InputStream input, Parser<O> parser) static Input
decodedInput
(String input) static Input
decodedInput
(String input, UtfErrorMode errorMode) static Input
decodedInput
(Input input) static Input
decodedInput
(Input input, UtfErrorMode errorMode) static <T> Output<T>
decodedOutput
(Output<T> output) Returns a newOutput
that accepts UTF-8 code unit sequences, and writes decoded Unicode code points to the composedoutput
, handling invalid code unit sequences according to theUtfErrorMode.fatal()
policy.static <T> Output<T>
decodedOutput
(Output<T> output, UtfErrorMode errorMode) Returns a newOutput
that accepts UTF-8 code unit sequences, and writes decoded Unicode code points to the composedoutput
, handling invalid code unit sequences according to theerrorMode
policy.static <O> Parser<O>
decodedParser
(Parser<O> parser) static <O> Parser<O>
decodedParser
(Parser<O> parser, UtfErrorMode errorMode) Returns a newOutput
that accepts UTF-8 code unit sequences, and writes decoded Unicode code points to a growableString
, handling invalid code unit sequences according to theUtfErrorMode.fatal()
policy.static <O> Decoder<O>
decodeOutput
(InputBuffer input, Output<O> output, UtfErrorMode errorMode) Writes the decoded Unicode code points of theinput
buffer to the givenoutput
, returning aDecoder
continuation that knows how to decode subsequent input buffers.static <O> Decoder<O>
decodeOutput
(Input input, Output<O> output) Writes the decoded Unicode code points of theinput
buffer to the givenoutput
, returning aDecoder
continuation that knows how to decode subsequent input buffers.static <T> Output<T>
encodedOutput
(Output<T> output) static <T> Output<T>
encodedOutput
(Output<T> output, UtfErrorMode errorMode) static <I,
O> Writer<I, O> encodedWriter
(Writer<I, O> writer) static <I,
O> Writer<I, O> encodedWriter
(Writer<I, O> writer, UtfErrorMode errorMode) static <O> Decoder<O>
outputDecoder
(Output<O> output) Returns a newDecoder
that writes decoded Unicode code points to the givenoutput
, handling invalid code unit sequences according to theUtfErrorMode.fatal()
policy.static <O> Decoder<O>
outputDecoder
(Output<O> output, UtfErrorMode errorMode) Returns a newDecoder
that writes decoded Unicode code points to the givenoutput
, handling invalid code unit sequences according to theerrorMode
policy.static <O> Parser<O>
parseDecoded
(Input input, Parser<O> parser) static <O> Parser<O>
parseDecoded
(Input input, Parser<O> parser, UtfErrorMode errorMode) parseString
(Input input) parseString
(Input input, StringBuilder builder) parseString
(Input input, StringBuilder builder, UtfErrorMode errorMode) parseString
(Input input, UtfErrorMode errorMode) static <O> O
read
(InputStream input, Parser<O> parser) static int
sizeOf
(int c) Returns the number of bytes in the UTF-8 encoding of the Unicode code pointc
; returns the size of the Unicode replacement character (U+FFFD
) for surrogates and invalid code points.static int
sizeOf
(int c, UtfErrorMode errorMode) Returns the number of bytes in the UTF-8 encoding of the Unicode code pointc
, handling invalid code unit sequences according to theerrorMode
policy.static int
Returns the number of bytes in the UTF-8 encoding the givenstring
, assuming the Unicode replacement character (U+FFFD
) replaces unpaired surrogates and invalid code points.static int
sizeOf
(String string, UtfErrorMode errorMode) Returns the number of bytes in the UTF-8 encoding the givenstring
, handling invalid code unit sequences according to theerrorMode
policy.stringParser
(StringBuilder builder) stringParser
(StringBuilder builder, UtfErrorMode errorMode) stringParser
(UtfErrorMode errorMode) static <I,
O> Writer<I, O> stringWriter
(O input) static <I,
O> Writer<I, O> stringWriter
(O input, UtfErrorMode errorMode) static <I,
O> Writer<I, O> writeEncoded
(Output<?> output, Writer<I, O> writer) static <I,
O> Writer<I, O> writeEncoded
(Output<?> output, Writer<I, O> writer, UtfErrorMode errorMode) static <O> Writer<?,
O> writeString
(Output<?> output, O input) static <O> Writer<?,
O> writeString
(Output<?> output, O input, UtfErrorMode errorMode)
-
Method Details
-
decodedInput
-
decodedInput
-
decodedInput
-
decodedInput
-
decodedOutput
Returns a newOutput
that accepts UTF-8 code unit sequences, and writes decoded Unicode code points to the composedoutput
, handling invalid code unit sequences according to theerrorMode
policy. -
decodedOutput
Returns a newOutput
that accepts UTF-8 code unit sequences, and writes decoded Unicode code points to the composedoutput
, handling invalid code unit sequences according to theUtfErrorMode.fatal()
policy. -
decodedString
Returns a newOutput
that accepts UTF-8 code unit sequences, and writes decoded Unicode code points to a growableString
, handling invalid code unit sequences according to theUtfErrorMode.fatal()
policy. The returnedOutput
accepts an unbounded number of UTF-8 code units, remaining permanently in the cont state, andbinds
aString
containing all decoded code points. -
encodedOutput
-
encodedOutput
-
stringParser
-
stringParser
-
stringParser
-
stringParser
-
parseString
public static Parser<String> parseString(Input input, StringBuilder builder, UtfErrorMode errorMode) -
parseString
-
parseString
-
parseString
-
stringWriter
-
stringWriter
-
writeString
-
writeString
-
outputDecoder
Returns a newDecoder
that writes decoded Unicode code points to the givenoutput
, handling invalid code unit sequences according to theerrorMode
policy. -
outputDecoder
Returns a newDecoder
that writes decoded Unicode code points to the givenoutput
, handling invalid code unit sequences according to theUtfErrorMode.fatal()
policy. -
decodeOutput
public static <O> Decoder<O> decodeOutput(InputBuffer input, Output<O> output, UtfErrorMode errorMode) Writes the decoded Unicode code points of theinput
buffer to the givenoutput
, returning aDecoder
continuation that knows how to decode subsequent input buffers. Handles invalid code unit sequences according to theerrorMode
policy. -
decodeOutput
Writes the decoded Unicode code points of theinput
buffer to the givenoutput
, returning aDecoder
continuation that knows how to decode subsequent input buffers. Handles invalid code unit sequences according to theUtfErrorMode.fatal()
policy. -
decodedParser
-
decodedParser
-
parseDecoded
-
parseDecoded
-
encodedWriter
-
encodedWriter
-
writeEncoded
public static <I,O> Writer<I,O> writeEncoded(Output<?> output, Writer<I, O> writer, UtfErrorMode errorMode) -
writeEncoded
-
decode
- Throws:
IOException
-
read
- Throws:
IOException
-
sizeOf
Returns the number of bytes in the UTF-8 encoding of the Unicode code pointc
, handling invalid code unit sequences according to theerrorMode
policy. Returns the size of theUtfErrorMode.replacementChar()
for surrogates and invalid code points, ifUtfErrorMode.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
), ifUtfErrorMode.isNonZero()
is `true`. -
sizeOf
public static int sizeOf(int c) Returns the number of bytes in the UTF-8 encoding of the Unicode code pointc
; returns the size of the Unicode replacement character (U+FFFD
) for surrogates and invalid code points. -
sizeOf
Returns the number of bytes in the UTF-8 encoding the givenstring
, handling invalid code unit sequences according to theerrorMode
policy. -
sizeOf
Returns the number of bytes in the UTF-8 encoding the givenstring
, assuming the Unicode replacement character (U+FFFD
) replaces unpaired surrogates and invalid code points.
-