3v4l.org

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

Function utf8tolocalencoding:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 36
Branch analysis from position: 10
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 36
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 24
Branch analysis from position: 36
Branch analysis from position: 9
filename:       /in/iaZI1
function name:  utf8ToLocalEncoding
number of ops:  38
compiled vars:  !0 = $s, !1 = $tmp
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                                     ~3      $2, 'WIN'
          7      > JMPNZ_EX                                         ~3      ~3, ->9
          8    >   BOOL                                             ~3      <true>
          9    > > JMPZ                                                     ~3, ->36
    5    10    >   INIT_FCALL                                               'explode'
         11        SEND_VAL                                                 '.'
         12        INIT_FCALL                                               'setlocale'
         13        SEND_VAL                                                 0
         14        SEND_VAL                                                 0
         15        DO_ICALL                                         $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                         $5      
         18        ASSIGN                                                   !1, $5
    6    19        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !1, 1
         20      > JMPZ_EX                                          ~7      ~7, ->24
         21    >   FETCH_DIM_R                                      ~8      !1, 1
         22        TYPE_CHECK                                   16  ~9      ~8
         23        BOOL                                             ~7      ~9
         24    > > JMPZ                                                     ~7, ->36
    7    25    >   BEGIN_SILENCE                                    ~10     
         26        INIT_FCALL_BY_NAME                                       'iconv'
         27        SEND_VAL_EX                                              'UTF-8'
         28        FETCH_DIM_R                                      ~11     !1, 1
         29        CONCAT                                           ~12     'cp', ~11
         30        CONCAT                                           ~13     ~12, '%2F%2FTRANSLIT'
         31        SEND_VAL_EX                                              ~13
         32        SEND_VAR_EX                                              !0
         33        DO_FCALL                                      0  $14     
         34        END_SILENCE                                              ~10
         35        ASSIGN                                                   !0, $14
    9    36    > > RETURN                                                   !0
   10    37*     > RETURN                                                   null

End of function utf8tolocalencoding

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

End of function localencodingtoutf8

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.41 ms | 1407 KiB | 23 Q