req.acceptsCharsets()
Return whether this request (req
) advertises that it is able to handle any of the specified character set(s), and if so, which one.
If more than one of the character sets passed in to this method are considered acceptable, then the first one will be returned. If none of the character sets are considered acceptable, this returns
false
.
req.acceptsCharsets(charset);
or:
req.acceptsCharsets(charset1, charset2, …);
Useful for advanced content negotiation where a client may or may not support certain character sets, such as Unicode (UTF-8).
If a request is sent with a "Accept-Charset: utf-8"
header:
req.acceptsCharsets('utf-8');
// -> 'utf-8'
req.acceptsCharsets('iso-8859-1', 'utf-16', 'utf-8');
// -> 'utf-8'
req.acceptsCharsets('utf-16');
// -> false
- This is implemented by examining the request's
Accept-Charset
header (see RFC-2616).- See the
accepts
module for the finer details of the header-parsing algorithm used in Sails/Express.