Exemplo n.º 1
0
 /**
  * Transform encoding
  *
  * @param Application $app
  */
 private function transEncoding(Application $app)
 {
     $ie = $app->request->inputEncoding;
     $to = $app->encoding;
     if ($ie === $to) {
         return;
     }
     // url上可能也有汉字啥的
     $app->request->url = Encoding::convert($app->request->url, $to, $ie);
     $app->request->uri = Encoding::convert($app->request->uri, $to, $ie);
     Encoding::convertArray($app->request->inputs, $to, $ie);
     // 经过转码后把转码过的数据写会,$_GET/$_POST也可能被访问
     foreach ($_GET as $key => $value) {
         if (isset($app->request->inputs[$key])) {
             $_GET[$key] = $app->request->inputs[$key];
         }
     }
     foreach ($_POST as $key => $value) {
         if (isset($app->request->inputs[$key])) {
             $_POST[$key] = $app->request->inputs[$key];
         }
     }
 }