3v4l.org

run code in 300+ PHP versions simultaneously
<?php function utf8ToLocalEncoding($s) { if (substr(PHP_OS, 0, 3) === 'WIN') { list(, $code) = explode(".", setlocale(LC_CTYPE, 0)); $s = @iconv("UTF-8", "cp" . $code . "//TRANSLIT", $s); } return $s; } function localEncodingToUtf8($s) { if (substr(PHP_OS, 0, 3) === 'WIN') { list(, $code) = explode(".", setlocale(LC_CTYPE, 0)); $s = @iconv("cp" . $code . "//TRANSLIT", "UTF-8", $s); } return $s; } $original = "šířéč"; $a = utf8toLocalEncoding($original); $b = localEncodingToUtf8($a); var_dump($original, $a, $b, $original === $b); var_dump(setlocale(LC_CTYPE, 0));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tRpZJ
function name:  (null)
number of ops:  24
compiled vars:  !0 = $original, !1 = $a, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, '%C5%A1%C3%AD%C5%99%C3%A9%C4%8D'
   20     1        INIT_FCALL                                               'utf8tolocalencoding'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
   21     5        INIT_FCALL                                               'localencodingtoutf8'
          6        SEND_VAR                                                 !1
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !2, $6
   23     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !1
         12        SEND_VAR                                                 !2
         13        IS_IDENTICAL                                     ~8      !0, !2
         14        SEND_VAL                                                 ~8
         15        DO_ICALL                                                 
   24    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'setlocale'
         18        SEND_VAL                                                 0
         19        SEND_VAL                                                 0
         20        DO_ICALL                                         $10     
         21        SEND_VAR                                                 $10
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Function utf8tolocalencoding:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/tRpZJ
function name:  utf8ToLocalEncoding
number of ops:  31
compiled vars:  !0 = $s, !1 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'substr'
          2        SEND_VAL                                                 'Linux'
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 3
          5        DO_ICALL                                         $2      
          6        IS_IDENTICAL                                             $2, 'WIN'
          7      > JMPZ                                                     ~3, ->29
    5     8    >   INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '.'
         10        INIT_FCALL                                               'setlocale'
         11        SEND_VAL                                                 0
         12        SEND_VAL                                                 0
         13        DO_ICALL                                         $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                         $5      
         16        FETCH_LIST_R                                     $6      $5, 1
         17        ASSIGN                                                   !1, $6
         18        FREE                                                     $5
    6    19        BEGIN_SILENCE                                    ~8      
         20        INIT_FCALL_BY_NAME                                       'iconv'
         21        SEND_VAL_EX                                              'UTF-8'
         22        CONCAT                                           ~9      'cp', !1
         23        CONCAT                                           ~10     ~9, '%2F%2FTRANSLIT'
         24        SEND_VAL_EX                                              ~10
         25        SEND_VAR_EX                                              !0
         26        DO_FCALL                                      0  $11     
         27        END_SILENCE                                              ~8
         28        ASSIGN                                                   !0, $11
    8    29    > > RETURN                                                   !0
    9    30*     > RETURN                                                   null

End of function utf8tolocalencoding

Function localencodingtoutf8:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/tRpZJ
function name:  localEncodingToUtf8
number of ops:  31
compiled vars:  !0 = $s, !1 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'substr'
          2        SEND_VAL                                                 'Linux'
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 3
          5        DO_ICALL                                         $2      
          6        IS_IDENTICAL                                             $2, 'WIN'
          7      > JMPZ                                                     ~3, ->29
   13     8    >   INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '.'
         10        INIT_FCALL                                               'setlocale'
         11        SEND_VAL                                                 0
         12        SEND_VAL                                                 0
         13        DO_ICALL                                         $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                         $5      
         16        FETCH_LIST_R                                     $6      $5, 1
         17        ASSIGN                                                   !1, $6
         18        FREE                                                     $5
   14    19        BEGIN_SILENCE                                    ~8      
         20        INIT_FCALL_BY_NAME                                       'iconv'
         21        CONCAT                                           ~9      'cp', !1
         22        CONCAT                                           ~10     ~9, '%2F%2FTRANSLIT'
         23        SEND_VAL_EX                                              ~10
         24        SEND_VAL_EX                                              'UTF-8'
         25        SEND_VAR_EX                                              !0
         26        DO_FCALL                                      0  $11     
         27        END_SILENCE                                              ~8
         28        ASSIGN                                                   !0, $11
   16    29    > > RETURN                                                   !0
   17    30*     > RETURN                                                   null

End of function localencodingtoutf8

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.78 ms | 1407 KiB | 23 Q