code: public static byte[] toBytes(String str) {
          if (str == null) {
              return null;
          }
          //optimization for ascii strings
          byte[] ascii = toAsciiBytes(str);
          if(ascii != null) return ascii;
          
          ByteBuffer bb = UTF8_CHARSET.encode(str);
          return getBytes(bb);
      }
docs: Convert the given string to a byte[] in using the {@link #UTF8_CHARSET} encoder.
  This is the inverse of {@link #toString(byte[])}. A null value is allowed, which
  begets a null result.
  
  @param str   String value to be converted.
  @return      Lossless, encoded value as a byte[], or null if str is null.