protected function encode($originalString)
    {
        $encodedString = '';
        $nowCodeString = '';
        $originalLength = strlen($originalString);
        for ($i = 0; $i < $originalLength; $i++) {
            $encodeMode = ($i % 2 == 0) ? 1 : 2; // Switch encoding odd/even
            switch ($encodeMode) {
                case 1: // Decimal code
                    $nowCodeString = '&#' . ord($originalString[$i]) . ';';
                    break;
                case 2: // Hexadecimal code
                    $nowCodeString = '&#x' . dechex(ord($originalString[$i])) . ';';
                    break;
                default:
                    return 'ERROR: wrong encoding mode.';
            }
            $encodedString .= $nowCodeString;
        }
        return $encodedString;
    }