Warning: pack(): Type H: not enough characters in string in

I’m trying to change the php code to be compatible with php 8.2.12 from php 6.0.0-dev. The code deals with hexadecimal so I’m a little confused with the output.

Here’s an example of the result of the code that came out, php 8.2.12

i 0
i 0
H8 0 << questionable result

Warning: pack(): Type H: not enough characters in string in C:xampphtdocsservicesparserinclude.php on line 683
H8 16000000
H8 0d000000

Previously in the php 6.0.0-dev version the result was

i 0
i 0
i 0 << questionable result
H8 16000000
H8 0d000000

So the value of format i 0 before H8 16000000 in php 8.2.12 is changed to H8 0 which makes an error “Warning: pack(): Type H: not enough characters in string in C:xampphtdocsparserinclude.php on line 683”

Can anyone help with this problem? Here is the complete code of the parser function

function parser($output, $input, $indexing, $blockheader)
{
    global $typearr, $stop_error_msg;
    $filearray = file($input, FILE_SKIP_EMPTY_LINES);
    $filesize = sizeof($filearray);
    $struct = explode("t", trim($filearray[0]));
    $col_names = explode("t", trim($filearray[1]));
    if ($blockheader == 1)
    {
        // Define or replace strsize() function
        // $block = strsize($struct);
        $block = count($struct); // Example replacement
        if ($indexing == 1)
            $block += 4;
        $filesize_bin = pack("i", ($filesize - 2));
        fwrite($output, $filesize_bin);
        $blockbin = pack("i", $block);
        fwrite($output, $blockbin);
    }
    for ($i = 2; $i < $filesize; $i++)
    {
        $store = 0;
        $temporary = explode("t", trim($filearray[$i]));
        if ($indexing == 1)
            fwrite($output, pack("i", $i - 2));
        for ($st = 0; $st < count($struct) - 1; $st++)
        {
            if ($temporary[$st] == '')
            {
                $stop_error_msg .= "<br>Empty cell. Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                return false;
            }

            if (stristr($struct[$st], 'string[') !== false)
            {
                preg_match("/^(string[)?([d]+)/", $struct[$st], $str_ret);
                if (strlen($temporary[$st]) >= $str_ret[2])
                {
                    $temporary[$st] = substr($temporary[$st], 0, $str_ret[2] - 1);
                    echo "<br>Warning! Text overflow. Tail of string had been cut: ROW:".($i+1)." COLUMN:".($st+1)." NAME:".$col_names[$st]." DATA:'".$temporary[$st]. "' SIZE:". $str_ret[2];
                }
                //if(strlen($temporary[$st]) >= 255 && stristr($input, 'Desc') !== false)
               // {
               //     echo "<br>Warning! Exceeded max length of 255 symbols at item description. Tail of string wont be shown in game: ROW:".($i+1)." COLUMN:".($st+1)." NAME:".$col_names[$st]." DATA:'".$temporary[$st]. "' SIZE:". $str_ret[2];
                    //$temporary[$st] = substr($temporary[$st], 0, 254);
               // }
                $resulthex = pack("a".$str_ret[2], trim(str_replace("x22x22x22x22", "x22x22", $temporary[$st]), "x22"));
                fwrite($output, $resulthex);
                continue;
            }
            $type = $typearr[$struct[$st]]['type'];
            switch($type)
            {
                case "xeh":
                    $resulthex = xeh($temporary[$st]);
                    break;
                case "xeh64":
                    $resulthex = xeh64($temporary[$st]);
                    break;
                case "clcode":
                    $resulthex = clcode($temporary[$st]);
                    break;
                case "exclcode":
                    if(($resulthex = exclcode($temporary[$st])) === false)
                    {
                        $stop_error_msg .= " Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                        return false;
                    }
                    break;
                case "ccode":
                    $resulthex = ccode($temporary[$st]);
                    break;
                case "f":
                case "d":
                    $trans = array("," => ".");
                    $resulthex = pack($type, strtr("".$temporary[$st]."", $trans));
                    break;
                case "bulltype":
                    if(($resulthex = bulltype($temporary[$st])) === false)
                    {
                        $stop_error_msg .= " Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                        return false;
                    }
                    break;
                case "bttype":
                    if(($resulthex = bttype($temporary[$st])) === false)
                    {
                        $stop_error_msg .= " Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                        return false;
                    }
                    break;
                case "effbttype":
                    if(($resulthex = effbttype($temporary[$st])) === false)
                    {
                        $stop_error_msg .= " Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                        return false;
                    }
                    break;
                case "stb":
                    if(($resulthex = stb($temporary[$st])) === false)
                    {
                        $stop_error_msg .= " Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                        return false;
                    }
                    break;
                case "stb4":
                    if(($resulthex = stb4($temporary[$st])) === false)
                    {
                        $stop_error_msg .= " Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                        return false;
                    }
                    break;
                case "stb12":
                    if(($resulthex = stb12($temporary[$st])) === false)
                    {
                        $stop_error_msg .= " Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                        return false;
                    }
                    break;
                case "stb16":
                    if(($resulthex = stb16($temporary[$st])) === false)
                    {
                        $stop_error_msg .= " Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                        return false;
                    }
                    break;
                case "res":
                    $resulthex = resource($temporary[0]);
                    break;
                case "qitid":
                    $resulthex = qitid($temporary[$st]);
                    break;
                case "lqitem":
                    $resulthex = lqitem($temporary[$st]);
                    break;
                case "store":
                    if(($resulthex = store($temporary[$st], $store, $temporary[10])) === false)
                    {
                        $stop_error_msg .= " Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                        return false;
                    }
                    $store++;
                    break;
                case "qcode":
                    $resulthex = qcode($temporary[$st]);
                    break;
                case "spcode":
                    $resulthex = spcode($temporary[$st]);
                    break;
                case "text":
                    $len = strlen($temporary[$st]);
                    $len = $len + 1;
                    $resulthex=pack("a".$len, $temporary[$st]);
                    $plen=pack("i", $len);
                    fwrite($output, $plen);
                    break;
                case "param":
                    if(($resulthex = param($temporary[$st], $temporary[$st+1])) === false)
                    {
                        $stop_error_msg .= " Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                        return false;
                    }
                    $st++;
                    break;
                default:
                    echo $type." ".$temporary[$st]."<br>";
                    $resulthex = pack($type, $temporary[$st]); # error indication is in this script
            }
            if(!empty($err_arr) && isset($err_arr['message']) && stripos($err_arr['message'], 'function.date') !== false) {
                $stop_error_msg .= "<br>Pack error. Probably mistake at excel file:<br>ROW:".($i+1)."<br>COLUMN:".($st+1)."<br>NAME:".$col_names[$st]."<br>DATA:".$temporary[$st];
                return false;
            }
            fwrite($output, $resulthex);
        }
    }
    return true;
}

I just tried to change the value of the $type variable to fix for the i format, but the result is still messy

default:
   echo "i" ".$temporary[$st]."<br>";
   $resulthex = pack("i", $temporary[$st]); # error indication is in this script
i0
i0
i0 << questionable result
i16000000 << changed to i format
i0d000000 << changed to i format

Do I need to add a new function to handle H8 format and make a separate case instead of default?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật