Name

langmatches_pct_http — compute the RFC 7231 quality value (q-factor) for a language tag against an Accept-Language header

Synopsis

integer langmatches_pct_http( in language_tag varchar,
  in accept_language varchar);
 

Description

Evaluates a BCP 47 language_tag (such as 'en', 'en-GB', 'fr-CA') against the contents of an HTTP Accept-Language accept_language header and returns an integer quality-percentage in the range 0..1000 (RFC 7231 q-values multiplied by 1000). The result is 0 if the language tag does not match any entry in the header. Returns SQL NULL if language_tag is NULL.

Use this function inside content-negotiation logic (for example in VSP/ VSPX handlers or SPARQL endpoint code) to pick the highest-priority language for a multi-lingual response.

Examples

Example 24.44. Simple Example

SQL> select langmatches_pct_http ('en-GB', 'fr;q=0.8, en;q=0.9, *;q=0.1');
-- 900
SQL> select langmatches_pct_http ('de',    'fr;q=0.8, en;q=0.9, *;q=0.1');
-- 100
      


© 1992 - OpenLink Software. All rights reserved.

Making Technology Work for You®