Revision 2 of 4, by Bart on 11-11-2023. The page as it is now.
$codePage
The global compiler directive {$codePage} indicates how to interpret string literals.
available code pages
The FPC can understand following code pages:
<table> <thead> <tr> <th>code page</th> <th>description</th> </tr> </thead> <tbody> <tr> <td><code>{$codePage CP437}</code></td> <td>Original IBM PC or DOS Latin US <a href="https://en.wikipedia.org/wiki/Code_page_437">code page 437</a></td> </tr> <tr> <td><code>{$codePage CP850}</code></td> <td>DOS Latin 1 <a href="https://en.wikipedia.org/wiki/Code_page_850">code page 850</a></td> </tr> <tr> <td><code>{$codePage CP852}</code></td> <td>DOS Latin 2 <a href="https://en.wikipedia.org/wiki/Code_page_852">code page 852</a></td> </tr> <tr> <td><code>{$codePage CP856}</code></td> <td>Hebrew, <a href="https://en.wikipedia.org/wiki/Code_page_856">code page 856</a></td> </tr> <tr> <td><code>{$codePage CP866}</code></td> <td>Cyrillic script, <a href="https://en.wikipedia.org/wiki/Code_page_866">code page 866</a></td> </tr> <tr> <td><code>{$codePage CP874}</code></td> <td>Thai, <a href="https://en.wikipedia.org/wiki/Code_page_874">ISO/IEC 8859‑11</a></td> </tr> <tr> <td><code>{$codePage CP1250}</code></td> <td><a href="https://en.wikipedia.org/wiki/Windows-1250">Windows‑1250</a></td> </tr> <tr> <td><code>{$codePage CP1251}</code></td> <td>Cyrillic script, <a href="https://en.wikipedia.org/wiki/Windows-1251">Windows‑1251</a></td> </tr> <tr> <td><code>{$codePage CP1252}</code></td> <td><a href="https://en.wikipedia.org/wiki/Windows-1252">Windows‑1252</a></td> </tr> <tr> <td><code>{$codePage CP1253}</code></td> <td>Greek script, <a href="https://en.wikipedia.org/wiki/Windows-1253">Windows‑1253</a></td> </tr> <tr> <td><code>{$codePage CP1254}</code></td> <td>Turkish, <a href="https://en.wikipedia.org/wiki/Windows-1254">Windows‑1254</a></td> </tr> <tr> <td><code>{$codePage CP1255}</code></td> <td>Hebrew, <a href="https://en.wikipedia.org/wiki/Windows-1255">Windows‑1255</a></td> </tr> <tr> <td><code>{$codePage CP1256}</code></td> <td>Arabic, <a href="https://en.wikipedia.org/wiki/Windows-1256">Windows‑1256</a></td> </tr> <tr> <td><code>{$codePage CP1257}</code></td> <td><a href="https://en.wikipedia.org/wiki/Windows-1257">Windows‑1257</a></td> </tr> <tr> <td><code>{$codePage CP1258}</code></td> <td>Vietnamese, <a href="https://en.wikipedia.org/wiki/Windows-1258">Windows-1258</a></td> </tr> <tr> <td><code>{$codePage 8859-1}</code></td> <td>ISO Latin-1, <a href="https://en.wikipedia.org/wiki/ISO/IEC_8859-1">ISO/IEC 8859‑1</a></td> </tr> <tr> <td><code>{$codePage 8859-2}</code></td> <td><a href="https://en.wikipedia.org/wiki/ISO/IEC_8859-2">ISO/IEC 8859‑2</a></td> </tr> <tr> <td><code>{$codePage 8859-5}</code></td> <td>Cyrillic script, <a href="https://en.wikipedia.org/wiki/ISO/IEC_8859-5">ISO/IEC 8859‑5</a></td> </tr> <tr> <td><code>{$codePage UTF-8}</code><br /> <code>{$codePage UTF8}</code></td> <td>pseudo code page to switch back to UTF-8</td> </tr> </tbody> </table>
The code page can be selected either via a compiler directive or as a command-line parameter: ‑Fc… (where … is one of the code page names listed above).
use
Since FPC 3.0.0 every ANSIString is associated with a CP.
see also
From the Free Pascal wiki, page "$codePage", as it stood on 2023-11-11 after a change by Bart, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
