Utility method to set content and charset at once.

@param sContent
The response content string. May not be <code>null</code>.
@param aCharset
The charset to use. May not be <code>null</code>.
@return this
765015
@Nonnull
  public final UnifiedResponse setContentAndCharset (@Nonnull final String sContent, @Nonnull final Charset aCharset)
  {
    ValueEnforcer.notNull (sContent, "Content");
    setCharset (aCharset);
    setContent (sContent.getBytes (aCharset));
    return this;
  }
1028814
public static function setDecoration(string $sContent, string $sStyleName) : string
    {
        return self::_applyCode($sContent, self::$_aBackgroundCodes[$sStyleName]);
    }
149574
public HttpClientResponseBuilder doReturnXML(String response, Charset charset) {
        return doReturn(response, charset).withHeader("Content-type", APPLICATION_XML.toString());
    }
723035
public Charset contentCharset() {
        String ct = contentType();
        if (ct != null) {
            int index = ct.indexOf("charset=");
            if (index != -1) {
                return Charset.forName(ct.substring(index + 8));
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
255105
public function setCharset($charset)
    {
        $this->charset = $charset;
        if (!$this->headerCharset) {
            $this->headerCharset = $charset;
        }

        return $this;
    }
140832
public void setContent(Region content) {
        if (content != null) {
            this.content = content;
            this.content.setPickOnBounds(false);
            contentHolder.getChildren().setAll(content);
        }
    }
1109379
public static HtmlTree META(String httpEquiv, String content, String charSet) {
        HtmlTree htmltree = new HtmlTree(HtmlTag.META);
        String contentCharset = content + "; charset=" + charSet;
        htmltree.addAttr(HtmlAttr.HTTP_EQUIV, nullCheck(httpEquiv));
        htmltree.addAttr(HtmlAttr.CONTENT, contentCharset);
        return htmltree;
    }
1254423
public RawResponse charset(Charset charset) {
        return new RawResponse(method, url, statusCode, statusLine, cookies, headers, body, charset, decompress);
    }
196748
public void setContent(Object content, String contentType)
			throws UnsupportedEncodingException {
		// https://code.google.com/p/sipservlets/issues/detail?id=202
		if(getSipSession().getProxy() == null) {
			checkMessageState();
		}
		checkContentType(contentType);
		checkCommitted();

		if(contentType != null && contentType.length() > 0) {
			this.addHeader(ContentTypeHeader.NAME, contentType);
			ContentTypeHeader contentTypeHeader = (ContentTypeHeader)this.message.getHeader(ContentTypeHeader.NAME);
			String charset = this.getCharacterEncoding();
			try {
			    // https://code.google.com/p/sipservlets/issues/detail?id=169
				if(contentType.contains(CONTENT_TYPE_MULTIPART) && content instanceof Multipart) {
					// Fix for Issue 2667 : Correct Handling of MimeMultipart
					Multipart multipart = (Multipart) content;
					OutputStream os = new ByteArrayOutputStream();
					multipart.writeTo(os);
					this.message.setContent(os.toString(), contentTypeHeader);
				} else {
					Object tmpContent = content;
					if(tmpContent instanceof String  && charset != null) {
						//test for unsupportedencoding exception
						new String("testEncoding".getBytes(charset));
						tmpContent = new String(((String)tmpContent).getBytes());
					}
					this.message.setContent(content, contentTypeHeader);
				}
			} catch (UnsupportedEncodingException uee) {
				throw uee;
			} catch (Exception e) {
				throw new IllegalArgumentException("Parse error reading content " + content + " with content type " + contentType, e);
			}
		}
	}
111651
public static void setChar (@Nonnull final CharSequence aSeq, final int nIndex, @Nonnull final Codepoint aCodepoint)
  {
    setChar (aSeq, nIndex, aCodepoint.getValue ());
  }
763911
public static function contentType($type, $charset = 'utf-8'){
        $type = isset( self::$types[$type] ) ? self::$types[$type] : $type;
        self::set('Content-Type: '. $type. '; charset='. $charset);
    }
608773
public void setUtf8Content(final Object content) throws MessagingException
	{
		final String type = EmailConstants.MIMETYPE_TEXT_PLAIN + EmailConstants.CHARSET_PREFIX
			+ EmailConstants.CHARSET_UTF8;
		setContent(content, type);
	}
483051
public static void decodeTo(String content, MultiMap<String> map, Charset charset) {
        if (charset == null)
            charset = ENCODING;

        if (charset == StandardCharsets.UTF_8) {
            decodeUtf8To(content, 0, content.length(), map);
            return;
        }

        synchronized (map) {
            String key = null;
            String value = null;
            int mark = -1;
            boolean encoded = false;
            for (int i = 0; i < content.length(); i++) {
                char c = content.charAt(i);
                switch (c) {
                    case '&':
                        int l = i - mark - 1;
                        value = l == 0 ? "" :
                                (encoded ? decodeString(content, mark + 1, l, charset) : content.substring(mark + 1, i));
                        mark = i;
                        encoded = false;
                        if (key != null) {
                            map.add(key, value);
                        } else if (value != null && value.length() > 0) {
                            map.add(value, "");
                        }
                        key = null;
                        value = null;
                        break;
                    case '=':
                        if (key != null)
                            break;
                        key = encoded ? decodeString(content, mark + 1, i - mark - 1, charset) : content.substring(mark + 1, i);
                        mark = i;
                        encoded = false;
                        break;
                    case '+':
                        encoded = true;
                        break;
                    case '%':
                        encoded = true;
                        break;
                }
            }

            if (key != null) {
                int l = content.length() - mark - 1;
                value = l == 0 ? "" : (encoded ? decodeString(content, mark + 1, l, charset) : content.substring(mark + 1));
                map.add(key, value);
            } else if (mark < content.length()) {
                key = encoded
                        ? decodeString(content, mark + 1, content.length() - mark - 1, charset)
                        : content.substring(mark + 1);
                if (key != null && key.length() > 0) {
                    map.add(key, "");
                }
            }
        }
    }
130364
public static Content content(String somePlainText) {
		Content c = null;
		try {
			c = new Content("text/plain; charset=UTF-8", somePlainText.getBytes("UTF-8"));
		} catch (UnsupportedEncodingException e) { /* UTF-8 is never unsupported */
		}
		return c;
	}
84886
public void setCharset(final Charset charset) {
        final Charset old = this.charset;

        this.charset = charset;
        this.connectionConfig = System.currentTimeMillis();
        this.connectionValidated = false;

        this.pcs.firePropertyChange("charset", old, this.charset);
    }
1107288
public void setContent(Content content) {
        setSize(content.getContent().length);
        setAttachmentContentId(content.getId());
    }
236477
@Override
    public void setContentType(String value) {
        if (isCommitted()) {
            return;
        }
        if (null == value) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "setContentType: null, removing header");
            }
            this.response.removeHeader("Content-Type");
            return;
        }
        boolean addEncoding = false;
        String type = value;

        // see if the input value contains a charset
        int charsetIndex = value.indexOf("charset=");
        if (-1 != charsetIndex) {
            if (null == this.outWriter) {
                // can update both mime-set and charset
                addEncoding = true;
                this.encoding = connection.getEncodingUtils().stripQuotes(value.substring(charsetIndex + 8));
            } else {
                // can only update the mimeset so strip the charset off
                type = value.substring(0, charsetIndex).trim();
                charsetIndex = -1;
            }
        }
        if (null != this.outWriter) {
            // can still update the mime-type but not charset
            addEncoding = true;
        } else {
            // TODO don't quite follow why webcontainer checks for text*
            if (type.startsWith("text")) {
                addEncoding = true;
            }
        }
        if (addEncoding) {
            if (-1 != charsetIndex) {
                type = type.substring(0, charsetIndex - 1);
            }
            if (this.encoding != null) {
                type = type + ";charset=" + this.encoding;
            }
        }
        this.contentType = type;
        this.response.setHeader("Content-Type", type);
    }