nl_tokens: Get the preferred charsets from an Accept - Charset header .
pl_tokens: function preferredCharsets ( accept , provided ) { // RFC 2616 sec 14.2: no header = * var accepts = parseAcceptCharset ( <mask> === undefined ? '*' : accept || '' ) ; if ( ! provided ) { // sorted list of all charsets return accepts . filter ( isQuality ) . sort ( compareSpecs ) . map ( getFullCharset ) ; } var priorities = provided . map ( function getPriority ( type , index ) { return getCharsetPriority ( type , accepts , index ) ; } ) ; // sorted list of accepted charsets return priorities . filter ( isQuality ) . sort ( compareSpecs ) . map ( function getCharset ( priority ) { return provided [ priorities . indexOf ( priority ) ] ; } ) ; }