code: public static byte[] encodeString(String s, boolean useUnicode)
              throws UnsupportedEncodingException {
          if (useUnicode) {
              return getUTFStringAsByteArray(s);
          }
  
          return getOEMStringAsByteArray(s);
      }
docs: Encodes the string to a byte array using UTF-16LE or the ASCII charset
  in function of the <code>useUnicode</code> argument.
  
  @param s the string to encode
  @param useUnicode if true then string is encoded to UTF-16LE
  otherwise to ASCII
  @return the encoded string as a byte array
  @throws UnsupportedEncodingException if encoding fails