downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  

<http_supporthttp_negotiate_content_type>
Last updated: Thu, 26 Jun 2008

http_negotiate_charset

(PECL pecl_http:0.1.0-1.5.5)

http_negotiate_charset — Negotiate clients preferred character set

Description

string http_negotiate_charset ( array $supported [, array &$result ] )

This function negotiates the clients preferred charset based on its Accept-Charset HTTP header. The qualifier is recognized and charsets without qualifier are rated highest.

Parameters

supported

array containing the supported charsets as values

result

will be filled with an array containing the negotiation results

Return Values

Returns the negotiated charset or the default charset (i.e. first array entry) if none match.

Examples

Example #1 Using http_negotiate_charset()

<?php
$charsets
= array(
      
'iso-8859-1', // default
      
'iso-8859-2',
      
'iso-8859-15',
      
'utf-8'
);

$pref = http_negotiate_charset($charsets, $result);

if (
strcmp($pref, 'iso-8859-1')) {
      
iconv_set_encoding('internal_encoding', 'iso-8859-1');
      
iconv_set_encoding('output_encoding', $pref);
      
ob_start('ob_iconv_handler');
}

print_r($result);
?>



add a noteadd a note User Contributed Notes
Negotiate clients preferred character set
There are no user contributed notes for this page.




<http_supporthttp_negotiate_content_type>
Last updated: Thu, 26 Jun 2008
show source | credits | sitemap | contact | advertising | mirror sites
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://phpbuilder.com/
Last updated: Tue Nov 1 20:20:59 2005 EST
Columns / Articles | Tips / Quickies | News | News Linking and RSS Feeds | Shared Code Library
Mail Archives | Support / Discussion Forums | Get Started! Links | Contribute! | Docs