1 /* 2 * Codepage functions 3 * 4 * Copyright (C) 2008-2021, Joachim Metz <joachim.metz@gmail.com> 5 * 6 * Refer to AUTHORS for acknowledgements. 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License 19 * along with this program. If not, see <https://www.gnu.org/licenses/>. 20 */ 21 22 #include <common.h> 23 #include <types.h> 24 25 #include "pyolecf_codepage.h" 26 #include "pyolecf_libolecf.h" 27 28 /* Returns a string representation of the codepage 29 * Codecs and aliases are defined: http://docs.python.org/library/codecs.html#standard-encodings 30 * Returns 1 if successful or NULL if codepage is not supported 31 */ pyolecf_codepage_to_string(int codepage)32const char *pyolecf_codepage_to_string( 33 int codepage ) 34 { 35 switch( codepage ) 36 { 37 case LIBOLECF_CODEPAGE_ASCII: 38 return( "ascii" ); 39 40 case LIBOLECF_CODEPAGE_ISO_8859_1: 41 return( "iso-8859-1" ); 42 43 case LIBOLECF_CODEPAGE_ISO_8859_2: 44 return( "iso-8859-2" ); 45 46 case LIBOLECF_CODEPAGE_ISO_8859_3: 47 return( "iso-8859-3" ); 48 49 case LIBOLECF_CODEPAGE_ISO_8859_4: 50 return( "iso-8859-4" ); 51 52 case LIBOLECF_CODEPAGE_ISO_8859_5: 53 return( "iso-8859-5" ); 54 55 case LIBOLECF_CODEPAGE_ISO_8859_6: 56 return( "iso-8859-6" ); 57 58 case LIBOLECF_CODEPAGE_ISO_8859_7: 59 return( "iso-8859-7" ); 60 61 case LIBOLECF_CODEPAGE_ISO_8859_8: 62 return( "iso-8859-8" ); 63 64 case LIBOLECF_CODEPAGE_ISO_8859_9: 65 return( "iso-8859-9" ); 66 67 case LIBOLECF_CODEPAGE_ISO_8859_10: 68 return( "iso-8859-10" ); 69 70 case LIBOLECF_CODEPAGE_ISO_8859_11: 71 return( "iso-8859-11" ); 72 73 case LIBOLECF_CODEPAGE_ISO_8859_13: 74 return( "iso-8859-13" ); 75 76 case LIBOLECF_CODEPAGE_ISO_8859_14: 77 return( "iso-8859-14" ); 78 79 case LIBOLECF_CODEPAGE_ISO_8859_15: 80 return( "iso-8859-15" ); 81 82 case LIBOLECF_CODEPAGE_ISO_8859_16: 83 return( "iso-8859-16" ); 84 85 case LIBOLECF_CODEPAGE_KOI8_R: 86 return( "koi8_r" ); 87 88 case LIBOLECF_CODEPAGE_KOI8_U: 89 return( "koi8_u" ); 90 91 case LIBOLECF_CODEPAGE_WINDOWS_874: 92 return( "cp874" ); 93 94 case LIBOLECF_CODEPAGE_WINDOWS_932: 95 return( "cp932" ); 96 97 case LIBOLECF_CODEPAGE_WINDOWS_936: 98 return( "cp936" ); 99 100 case LIBOLECF_CODEPAGE_WINDOWS_949: 101 return( "cp949" ); 102 103 case LIBOLECF_CODEPAGE_WINDOWS_950: 104 return( "cp950" ); 105 106 case LIBOLECF_CODEPAGE_WINDOWS_1250: 107 return( "cp1250" ); 108 109 case LIBOLECF_CODEPAGE_WINDOWS_1251: 110 return( "cp1251" ); 111 112 case LIBOLECF_CODEPAGE_WINDOWS_1252: 113 return( "cp1252" ); 114 115 case LIBOLECF_CODEPAGE_WINDOWS_1253: 116 return( "cp1253" ); 117 118 case LIBOLECF_CODEPAGE_WINDOWS_1254: 119 return( "cp1254" ); 120 121 case LIBOLECF_CODEPAGE_WINDOWS_1255: 122 return( "cp1255" ); 123 124 case LIBOLECF_CODEPAGE_WINDOWS_1256: 125 return( "cp1256" ); 126 127 case LIBOLECF_CODEPAGE_WINDOWS_1257: 128 return( "cp1257" ); 129 130 case LIBOLECF_CODEPAGE_WINDOWS_1258: 131 return( "cp1258" ); 132 133 default: 134 break; 135 } 136 return( NULL ); 137 } 138 139