writeUtf8

common
open override fun writeUtf8(string: String): Buffer

Encodes string in UTF-8 and writes it to this sink.

Buffer buffer = new Buffer();
buffer.writeUtf8("Uh uh uh!");
buffer.writeByte(' ');
buffer.writeUtf8("You didn't say the magic word!");

assertEquals("Uh uh uh! You didn't say the magic word!", buffer.readUtf8());
open override fun writeUtf8(string: String): Buffer
open override fun writeUtf8(string: String, beginIndex: Int, endIndex: Int): Buffer
common
open override fun writeUtf8(string: String, beginIndex: Int, endIndex: Int): Buffer

Encodes the characters at beginIndex up to endIndex from string in UTF-8 and writes it to this sink.

Buffer buffer = new Buffer();
buffer.writeUtf8("I'm a hacker!\n", 6, 12);
buffer.writeByte(' ');
buffer.writeUtf8("That's what I said: you're a nerd.\n", 29, 33);
buffer.writeByte(' ');
buffer.writeUtf8("I prefer to be called a hacker!\n", 24, 31);

assertEquals("hacker nerd hacker!", buffer.readUtf8());