opened
Waxter81
username_0
Configured Charset ISO-8859-1 with decode_utf8 enabled:
```
$jaxon->setOption('core.encoding', 'ISO-8859-1');
$jaxon->setOption('core.decode_utf8', true);
```
I make a Jaxon Request with rq()->form(), like this:
```
<form id="formulario">
    <!-- The crux of this page -->
    Enter your name:
    <input type="text" name="username" id="username" />
    <input type="button" value="Submit" onclick=" <?php echo rq()->call('Ajax.Test.hello',rq()->form('formulario'))?>" />
</form>    
```

In Request/Manager.php, there is a process() method that decodes input utf-8 parameters:
```
$mFunction = array(&$this, '__argumentDecodeUTF8_' . $sFunction);
array_walk($this->aArgs, $mFunction);
```
In my case, it's calling next method: 
```
    private function __argumentDecodeUTF8_iconv(&$mArg)
    {
        if(is_array($mArg))
        {
            foreach($mArg as $sKey => $xArg)
            {
                $sNewKey = $sKey;
                $this->__argumentDecodeUTF8_iconv($sNewKey);
                if($sNewKey != $sKey)
                {
                    $mArg[$sNewKey] = $xArg;
                    unset($mArg[$sKey]);
                    $sKey = $sNewKey;
                }
                $this->__argumentDecodeUTF8_iconv($xArg);
            }
        }
        elseif(is_string($mArg))
        {
            $mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg);
        }
        error_log(print_r($mArg,true));
    }
```
**Previous method is not working when $mArg is an Array. It decodes ok individually each $sKey and each $xArg, but at the end of the recursive function, the arguments array stay inaltered, hasn't been decoded from utf-8.**

I've fixed declaring this method instead:
```
    private function myArgumentDecodeUTF8_iconv($mArg)
    {
    	if(is_array($mArg)) {
    		array_walk_recursive($mArg, function(&$item, $key){
    			$item = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $item);    			
    		});
    	}
    	elseif(is_string($mArg))
    	{
    		$mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg);
    	}
    	
    	return $mArg;
    }
```
And calling it like this: 
`if($sFunction == "iconv") $this->aArgs = $this->myArgumentDecodeUTF8_iconv($this->aArgs);`
Decoding UTF-8 parameters from FormValues
issue
created
feuzeu
username_1
Hi,
Can you please provide some input data so I can reproduce the issue and test the fix?
Thanks.
comment
created
Waxter81
username_0
test.php:
```
<?php 
header('Content-type: text/html; charset=iso-8859-1');
require(__DIR__ . '/jaxon/defs.php');
?>

<!doctype html>
<html>
<head></head>
<body>
<form id="formulario">
    <!-- The crux of this page -->
    Enter your name:
    <input type="text" name="username" id="username" />
    <input type="button" value="Form Test" onclick=" <?php echo rq()->call('Ajax.Test.foo',rq()->form('formulario'))?>" />
    <input type="button" value="Select Test" onclick=" <?php echo rq()->call('Ajax.Test.foo',rq()->select('username'))?>" />
</form> 
</body>

<div id="jaxon-code">
<?php
$jaxon = jaxon();
echo $jaxon->getScript(true,true);
?>
</div>
</html>
```
Jaxon Test Class:
```
<?php
namespace Ajax;
use Jaxon\Response\Response;          // and the Response class

class Test {
	
	protected $response;
	
	public function __construct()
	{
		$this->response = new Response;
	}
	public function foo($param) {
    		
		$response = new Response();          // Instance the response class		
			
		if(is_array($param)) error_log($param['username']);				
		if(is_string($param)) error_log($param);				
		
		return $response;                    // Return the response to the jaxon engine
	}	
}
?>
```

# **Input Data in Form: López**

Test 1: Click on "Form Test" button in Form.
Test 2: Click on "Select Test" button in Form.

```
Output log:
[04-Apr-2018 23:42:27 Europe/Amsterdam] LÃ³pez
[04-Apr-2018 23:42:42 Europe/Amsterdam] López
```

Jaxon RequestManager (__argumentDecodeUTF8_iconv method) is not decoding UTF-8 to ISO-8859-1 when $this->aArgs is an Array.
comment