code: static public int stringToBytes(String string, byte[] buffer, int index) {
          byte[] bytes = string.getBytes();
          int length = bytes.length;
          System.arraycopy(bytes, 0, buffer, index, length);
          return length;
      }
docs: This function converts a string into its corresponding byte format and inserts
  it into the specified buffer at the specified index.
  
  @param string The string to be converted.
  @param buffer The byte array.
  @param index The index in the array to begin inserting bytes.
  @return The number of bytes inserted.