Converts strings to the right encoding in incoming and outgoing packets.

This plugin can be deactivated if all three tiers (DB, PHP, client) use the same charset, usually utf8. This works for nested objects.

package Amfphp_Plugins_CharsetConverter
author Ariel Sommeria-Klein

 Methods

constructor.

__construct(array $config) 

Parameters

$config

array

optional key/value pairs in an associative array. Used to override default configuration values.

converts the strings note: This is not a recursive function.

convertStringFromClientToPhpCharsets(mixed $obj) : mixed

Rather the recursion is handled by Amfphp_Core_Amf_Util::applyFunctionToContainedObjects. must be public so that Amfphp_Core_Amf_Util::applyFunctionToContainedObjects can call it

Parameters

$obj

mixed

Returns

mixed

note: This is not a recursive function.

convertStringFromPhpToClientCharsets(mixed $obj) : mixed

Rather the recusrion is handled by Amfphp_Core_Amf_Util::applyFunctionToContainedObjects. must be public so that Amfphp_Core_Amf_Util::applyFunctionToContainedObjects can call it

Parameters

$obj

mixed

Returns

mixed

converts untyped objects to their typed counterparts.

filterDeserializedRequest(mixed $deserializedRequest) : mixed

Loads the class if necessary

Parameters

$deserializedRequest

mixed

Returns

mixed

looks at the response and sets the explicit type field so that the serializer sends it properly

filterDeserializedResponse(mixed $deserializedResponse) : mixed

Parameters

$deserializedResponse

mixed

Returns

mixed

convert the string.

transliterate(String $string, int $direction) : String

finds the proper encoding depending on direction

Parameters

$string

String

data to convert

$direction

int

one of the DIRECTION_XXX consts described above

Returns

String

 Properties

 

$clientCharset : String

default utf-8 See all the possible codepages for iconv here: http://www.gnu.org/software/libiconv/

 

$method : String

One of the METHOD_XXX consts defined above.

 

$phpCharset : String

See all the possible codepages for iconv here: http://www.gnu.org/software/libiconv/

 Constants

 

transliterate direction

DIRECTION_CLIENT_TO_PHP 
 

transliterate direction

DIRECTION_PHP_TO_CLIENT 
 

uses the iconv library for reencoding

METHOD_ICONV 
 

uses the mbstring library for reencoding

METHOD_MBSTRING 
 

don't do anything

METHOD_NONE 
 

uses the recode library for reencoding

METHOD_RECODE 
 

uses the XML function utf8_decode and encode for reencoding - ISO-8859-1 only

METHOD_UTF8_DECODE