main

square/leakcanary

Last updated at: 29/12/2023 09:39

ByteStringCompat.java

TLDR

This file provides a static method, encodeUtf8, that is used for encoding a given string as UTF-8.

Methods

encodeUtf8

This method is used to encode a given string as UTF-8. It takes a string as a parameter and returns a ByteString object. This method is deprecated and should not be called from Kotlin. It is recommended to use the Kotlin extension function for UTF-8 encoding instead.

Classes

None

package shark.internal;

import okio.ByteString;

class ByteStringCompat {

  /**
   * This is deprecated (error) to invoke from Kotlin but invoking the Kotlin extension function
   * leads to improper bytecode that goes through the companion class.
   */
  static ByteString encodeUtf8(String string) {
    return ByteString.encodeUtf8(string);
  }
}