Edit Page

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.

Usage

req.acceptsCharsets(charset);

or:

  • req.acceptsCharsets(charset1, charset2, …);

Details

Useful for advanced content negotiation where a client may or may not support certain character sets, such as Unicode (UTF-8).

Example

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

Notes

  • 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.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Check out the official Sails VS Code extension

Documentation

Reference

Sails logo

Reference

AltStyle によって変換されたページ (->オリジナル) /