| 1 | 1 | | The [[global compiler directives|global compiler directive]] `{$codePage}` indicates how to interpret [[string]] literals. |
| 2 | 2 | | |
| 3 | 3 | | ## available code pages |
| 4 | 4 | | |
| 5 | 5 | | The [[FPC]] can understand following code pages: |
| 6 | 6 | | |
| 7 | | - | <table> |
| 8 | 7 | | <thead> |
| 9 | | - | <tr> |
| 10 | | - | <th>code page</th> |
| 11 | | - | <th>description</th> |
| 12 | | - | </tr> |
| 8 | + | |
| 13 | 9 | | </thead> |
| 14 | 10 | | <tbody> |
| 15 | | - | <tr> |
| 16 | | - | <td><code>{$codePage CP437}</code></td> |
| 17 | | - | <td>Original IBM PC or DOS Latin US <a href="https://en.wikipedia.org/wiki/Code_page_437">code page 437</a></td> |
| 18 | | - | </tr> |
| 19 | | - | <tr> |
| 20 | | - | <td><code>{$codePage CP850}</code></td> |
| 21 | | - | <td>DOS Latin 1 <a href="https://en.wikipedia.org/wiki/Code_page_850">code page 850</a></td> |
| 22 | | - | </tr> |
| 23 | | - | <tr> |
| 24 | | - | <td><code>{$codePage CP852}</code></td> |
| 25 | | - | <td>DOS Latin 2 <a href="https://en.wikipedia.org/wiki/Code_page_852">code page 852</a></td> |
| 26 | | - | </tr> |
| 27 | | - | <tr> |
| 28 | | - | <td><code>{$codePage CP856}</code></td> |
| 29 | | - | <td>Hebrew, <a href="https://en.wikipedia.org/wiki/Code_page_856">code page 856</a></td> |
| 30 | | - | </tr> |
| 31 | | - | <tr> |
| 32 | | - | <td><code>{$codePage CP866}</code></td> |
| 33 | | - | <td>Cyrillic script, <a href="https://en.wikipedia.org/wiki/Code_page_866">code page 866</a></td> |
| 34 | | - | </tr> |
| 35 | | - | <tr> |
| 36 | | - | <td><code>{$codePage CP874}</code></td> |
| 37 | | - | <td>Thai, <a href="https://en.wikipedia.org/wiki/Code_page_874">ISO/IEC 8859‑11</a></td> |
| 38 | | - | </tr> |
| 39 | | - | <tr> |
| 40 | | - | <td><code>{$codePage CP1250}</code></td> |
| 41 | | - | <td><a href="https://en.wikipedia.org/wiki/Windows-1250">Windows‑1250</a></td> |
| 42 | | - | </tr> |
| 43 | | - | <tr> |
| 44 | | - | <td><code>{$codePage CP1251}</code></td> |
| 45 | | - | <td>Cyrillic script, <a href="https://en.wikipedia.org/wiki/Windows-1251">Windows‑1251</a></td> |
| 46 | | - | </tr> |
| 47 | | - | <tr> |
| 48 | | - | <td><code>{$codePage CP1252}</code></td> |
| 49 | | - | <td><a href="https://en.wikipedia.org/wiki/Windows-1252">Windows‑1252</a></td> |
| 50 | | - | </tr> |
| 51 | | - | <tr> |
| 52 | | - | <td><code>{$codePage CP1253}</code></td> |
| 53 | | - | <td>Greek script, <a href="https://en.wikipedia.org/wiki/Windows-1253">Windows‑1253</a></td> |
| 54 | | - | </tr> |
| 55 | | - | <tr> |
| 56 | | - | <td><code>{$codePage CP1254}</code></td> |
| 57 | | - | <td>Turkish, <a href="https://en.wikipedia.org/wiki/Windows-1254">Windows‑1254</a></td> |
| 58 | | - | </tr> |
| 59 | | - | <tr> |
| 60 | | - | <td><code>{$codePage CP1255}</code></td> |
| 61 | | - | <td>Hebrew, <a href="https://en.wikipedia.org/wiki/Windows-1255">Windows‑1255</a></td> |
| 62 | | - | </tr> |
| 63 | | - | <tr> |
| 64 | | - | <td><code>{$codePage CP1256}</code></td> |
| 65 | | - | <td>Arabic, <a href="https://en.wikipedia.org/wiki/Windows-1256">Windows‑1256</a></td> |
| 66 | | - | </tr> |
| 67 | | - | <tr> |
| 68 | | - | <td><code>{$codePage CP1257}</code></td> |
| 69 | | - | <td><a href="https://en.wikipedia.org/wiki/Windows-1257">Windows‑1257</a></td> |
| 70 | | - | </tr> |
| 71 | | - | <tr> |
| 72 | | - | <td><code>{$codePage CP1258}</code></td> |
| 73 | | - | <td>Vietnamese, <a href="https://en.wikipedia.org/wiki/Windows-1258">Windows-1258</a></td> |
| 74 | | - | </tr> |
| 75 | | - | <tr> |
| 76 | | - | <td><code>{$codePage 8859-1}</code></td> |
| 77 | | - | <td>ISO Latin-1, <a href="https://en.wikipedia.org/wiki/ISO/IEC_8859-1">ISO/IEC 8859‑1</a></td> |
| 78 | | - | </tr> |
| 79 | | - | <tr> |
| 80 | | - | <td><code>{$codePage 8859-2}</code></td> |
| 81 | | - | <td><a href="https://en.wikipedia.org/wiki/ISO/IEC_8859-2">ISO/IEC 8859‑2</a></td> |
| 82 | | - | </tr> |
| 83 | | - | <tr> |
| 84 | | - | <td><code>{$codePage 8859-5}</code></td> |
| 85 | | - | <td>Cyrillic script, <a href="https://en.wikipedia.org/wiki/ISO/IEC_8859-5">ISO/IEC 8859‑5</a></td> |
| 86 | | - | </tr> |
| 87 | | - | <tr> |
| 88 | | - | <td><code>{$codePage UTF-8}</code><br /> |
| 11 | + | |
| 89 | 12 | | <code>{$codePage UTF8}</code></td> |
| 90 | | - | <td>pseudo code page to switch back to UTF-8</td> |
| 91 | | - | </tr> |
| 13 | + | |
| 92 | 14 | | </tbody> |
| 93 | | - | </table> |
| 94 | 15 | | |
| 95 | 16 | | 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). |
| 96 | 17 | | |
| 97 | 18 | | ## use |
| 98 | 19 | | |
| 99 | 20 | | Since [[FPC New Features 3.0.0|FPC 3.0.0]] every [[Ansistring|ANSIString]] is associated with a CP. |
| 100 | 21 | | |
| 101 | 22 | | ## see also |
| 102 | 23 | | |
| 103 | 24 | | - [[FPC Unicode support|FPC Unicode support § “source file code page”]] |
| 104 | 25 | | - [“`$CODEPAGE`: Set the source codepage”](https://freepascal.org/docs-html/current/prog/progsu88.html) |
| 105 | 26 | | - [[Language Codes]] |
| 106 | 27 | | |
| 107 | 28 | | --- |
| 108 | 29 | | *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](/wiki-contact).* |
| 109 | 30 | | Category: Global compiler directives |