{"record":{"id":"893faf5260b3a4d1","repo":"PHPOffice/PhpSpreadsheet","slug":"code-page-codepage-not-supported","errorCode":null,"errorMessage":"Code page $codePage not supported.","messagePattern":"Code page \\$codePage not supported\\.","errorType":"exception","errorClass":"PhpOffice\\PhpSpreadsheet\\Exception","httpStatus":null,"severity":"error","filePath":"src/PhpSpreadsheet/Shared/CodePage.php","lineNumber":104,"sourceCode":"    {\n        if (array_key_exists($codePage, self::$pageArray)) {\n            $value = self::$pageArray[$codePage];\n            if (is_array($value)) {\n                foreach ($value as $encoding) {\n                    if (@iconv('UTF-8', $encoding, ' ') !== false) {\n                        self::$pageArray[$codePage] = $encoding;\n\n                        return $encoding;\n                    }\n                }\n\n                throw new PhpSpreadsheetException(\"Code page $codePage not implemented on this system.\");\n            } else {\n                return $value;\n            }\n        }\n        if ($codePage == 720 || $codePage == 32769) {\n            throw new PhpSpreadsheetException(\"Code page $codePage not supported.\"); //    OEM Arabic\n        }\n\n        throw new PhpSpreadsheetException('Unknown codepage: ' . $codePage);\n    }\n\n    /** @return array<int, array<int, string>|string> */\n    public static function getEncodings(): array\n    {\n        return self::$pageArray;\n    }\n}\n","sourceCodeStart":86,"sourceCodeEnd":116,"githubUrl":"https://github.com/PHPOffice/PhpSpreadsheet/blob/65b080eef4d9fd11a5796135ab145883e5c3d6a6/src/PhpSpreadsheet/Shared/CodePage.php#L86-L116","documentation":"CodePage::numberToName() explicitly rejects code page 720 (DOS OEM Arabic) and 32769 with 'not supported' before attempting any mapping, because no unambiguous iconv encoding exists for them. Any string content in such a workbook is therefore unreadable by the Xls reader.","triggerScenarios":"Loading an .xls whose CODEPAGE record is 720 — Arabic DOS-era files, typically from old accounting or POS software — or the internal 32769 value.","commonSituations":"Archived Arabic-region spreadsheets from the 1990s; exports from legacy Middle-East business systems; files passed through old conversion pipelines.","solutions":["Re-save the file from LibreOffice/Excel choosing a modern encoding (UTF-8 or Windows-1256): libreoffice --headless --convert-to xlsx file.xls","If you must parse it, pre-convert the bytes yourself treating the code page as CP720 before handing the file over","Keep such files out of automated pipelines by validating the code page on ingest"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Reject/redirect unsupported legacy code pages at ingest\n$fh = fopen($path, 'rb');\n$head = fread($fh, 8); // OLE2 check D0 CF 11 E0 ...\nfclose($fh);\nif (substr(bin2hex($head), 0, 8) !== 'd0cf11e0') {\n    throw new InvalidArgumentException('Not an OLE2 .xls file');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $spreadsheet = $reader->load($path);\n} catch (\\PhpOffice\\PhpSpreadsheet\\Exception $e) {\n    if (str_contains($e->getMessage(), 'not supported')) {\n        // CP720/32769: route file to LibreOffice conversion pipeline\n    }\n}","preventionTips":["Pre-convert DOS-era Arabic files with LibreOffice before automated processing","Keep unsupported-encoding files out of batch pipelines via ingest checks","Archive originals; work from converted copies"],"tags":["xls","codepage","arabic","legacy","encoding"],"backgroundTag":"unsupported-encoding","analyzedSha":"65b080eef4d9fd11a5796135ab145883e5c3d6a6","analyzedAt":"2026-08-17T05:40:41.646Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}