Fix: make debugger work correctly when any field value is LATIN-1
[plcapi.git] / debugger / common.php
index 6404197..89a995b 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
  * @author Gaetano Giunta
- * @copyright (C) 2005-2013 G. Giunta
+ * @copyright (C) 2005-2014 G. Giunta
  * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt
  *
  * @todo switch params for http compression from 0,1,2 to values to be used directly
     $_GET = array_map('stripslashes_deep', $_GET);
   }
 
+  $preferredEncodings = 'UTF-8, ASCII, ISO-8859-1, UTF-7, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP';
+  $inputcharset = mb_detect_encoding(urldecode($_SERVER['REQUEST_URI']), $preferredEncodings);
 
   if ( isset( $_GET['usepost'] ) && $_GET['usepost'] === 'true' )
   {
       $_GET = $_POST;
+      $inputcharset = mb_detect_encoding(implode('', $_GET), $preferredEncodings);
   }
 
 // recover input parameters