/// <summary> /// Parses the accepted char sets and matches them against the supported encodings for the given <paramref name="payloadKind"/>. /// </summary> /// <param name="acceptCharsetHeader">The Accept-Charset header of the request.</param> /// <param name="payloadKind">The <see cref="ODataPayloadKind"/> for which to compute the encoding.</param> /// <param name="mediaType">The media type used to compute the default encoding for the payload.</param> /// <param name="useDefaultEncoding">true if the default encoding should be returned if no acceptable charset is found; otherwise false.</param> /// <returns>The encoding to be used for the response.</returns> private static Encoding GetEncoding(string acceptCharsetHeader, ODataPayloadKind payloadKind, ODataMediaType mediaType, bool useDefaultEncoding) { if (payloadKind == ODataPayloadKind.BinaryValue) { return(null); } return(HttpUtils.EncodingFromAcceptableCharsets( acceptCharsetHeader, mediaType, /*utf8Encoding*/ encodingUtf8NoPreamble, /*useDefaultEncoding*/ useDefaultEncoding ? encodingUtf8NoPreamble : null)); }