private function hexToInt($s, $i)
    {
        $j = (int) $i * 2;
        $k = 0;
        $s1 = (string) $s;

        // Get the character at position $j.
        $c = substr($s1, $j, 1);

        // Get the character at position $j + 1.
        $c1 = substr($s1, $j + 1, 1);

        switch ($c) {
            case 'A':
                $k += 160;
                break;
            case 'B':
                $k += 176;
                break;
            case 'C':
                $k += 192;
                break;
            case 'D':
                $k += 208;
                break;
            case 'E':
                $k += 224;
                break;
            case 'F':
                $k += 240;
                break;
            case ' ':
                $k += 0;
                break;
            default:
                $k = $k + (16 * (int) $c);
                break;
        }

        switch ($c1) {
            case 'A':
                $k += 10;
                break;
            case 'B':
                $k += 11;
                break;
            case 'C':
                $k += 12;
                break;
            case 'D':
                $k += 13;
                break;
            case 'E':
                $k += 14;
                break;
            case 'F':
                $k += 15;
                break;
            case ' ':
                $k += 0;
                break;
            default:
                $k += (int) $c1;
                break;
        }

        return $k;
    }