LCOV - differential code coverage report
Current view: top level - src/backend/utils/mb/conversion_procs/cyrillic_and_mic - cyrillic_and_mic.c (source / functions) Coverage Total Hit CBC
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 100.0 % 181 181 181
Current Date: 2025-09-06 07:49:51 +0900 Functions: 100.0 % 41 41 41
Baseline: lcov-20250908-010021-baseline Line coverage date bins:
Baseline Date: 2025-09-05 08:21:35 +0100 (30,360] days: 100.0 % 1 1 1
Legend: Lines:     hit not hit (360..) days: 100.0 % 180 180 180
Function coverage date bins:
(30,360] days: 100.0 % 1 1 1
(360..) days: 100.0 % 40 40 40

 Age         Owner                  TLA  Line data    Source code
                                  1                 : /*-------------------------------------------------------------------------
                                  2                 :  *
                                  3                 :  *    Cyrillic and MULE_INTERNAL
                                  4                 :  *
                                  5                 :  * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
                                  6                 :  * Portions Copyright (c) 1994, Regents of the University of California
                                  7                 :  *
                                  8                 :  * IDENTIFICATION
                                  9                 :  *    src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c
                                 10                 :  *
                                 11                 :  *-------------------------------------------------------------------------
                                 12                 :  */
                                 13                 : 
                                 14                 : #include "postgres.h"
                                 15                 : #include "fmgr.h"
                                 16                 : #include "mb/pg_wchar.h"
                                 17                 : 
  166 tgl@sss.pgh.pa.us          18 CBC           6 : PG_MODULE_MAGIC_EXT(
                                 19                 :                     .name = "cyrillic_and_mic",
                                 20                 :                     .version = PG_VERSION
                                 21                 : );
                                 22                 : 
 8353                            23               3 : PG_FUNCTION_INFO_V1(koi8r_to_mic);
                                 24               6 : PG_FUNCTION_INFO_V1(mic_to_koi8r);
                                 25               6 : PG_FUNCTION_INFO_V1(iso_to_mic);
                                 26               6 : PG_FUNCTION_INFO_V1(mic_to_iso);
                                 27               3 : PG_FUNCTION_INFO_V1(win1251_to_mic);
                                 28               3 : PG_FUNCTION_INFO_V1(mic_to_win1251);
 7490 bruce@momjian.us           29               3 : PG_FUNCTION_INFO_V1(win866_to_mic);
                                 30               3 : PG_FUNCTION_INFO_V1(mic_to_win866);
 8353 tgl@sss.pgh.pa.us          31               3 : PG_FUNCTION_INFO_V1(koi8r_to_win1251);
                                 32               3 : PG_FUNCTION_INFO_V1(win1251_to_koi8r);
 7490 bruce@momjian.us           33               3 : PG_FUNCTION_INFO_V1(koi8r_to_win866);
                                 34               3 : PG_FUNCTION_INFO_V1(win866_to_koi8r);
                                 35               3 : PG_FUNCTION_INFO_V1(win866_to_win1251);
                                 36               3 : PG_FUNCTION_INFO_V1(win1251_to_win866);
 8353 tgl@sss.pgh.pa.us          37               6 : PG_FUNCTION_INFO_V1(iso_to_koi8r);
                                 38               3 : PG_FUNCTION_INFO_V1(koi8r_to_iso);
                                 39               3 : PG_FUNCTION_INFO_V1(iso_to_win1251);
                                 40               3 : PG_FUNCTION_INFO_V1(win1251_to_iso);
 7490 bruce@momjian.us           41               3 : PG_FUNCTION_INFO_V1(iso_to_win866);
                                 42               3 : PG_FUNCTION_INFO_V1(win866_to_iso);
                                 43                 : 
                                 44                 : /* ----------
                                 45                 :  * conv_proc(
                                 46                 :  *      INTEGER,    -- source encoding id
                                 47                 :  *      INTEGER,    -- destination encoding id
                                 48                 :  *      CSTRING,    -- source string (null terminated C string)
                                 49                 :  *      CSTRING,    -- destination string (null terminated C string)
                                 50                 :  *      INTEGER,    -- source string length
                                 51                 :  *      BOOL        -- if true, don't throw an error if conversion fails
                                 52                 :  * ) returns INTEGER;
                                 53                 :  *
                                 54                 :  * Returns the number of bytes successfully converted.
                                 55                 :  * ----------
                                 56                 :  */
                                 57                 : 
                                 58                 : /*
                                 59                 :  * Cyrillic support
                                 60                 :  * currently supported Cyrillic encodings:
                                 61                 :  *
                                 62                 :  * KOI8-R (this is also the charset for the mule internal code for Cyrillic)
                                 63                 :  * ISO-8859-5
                                 64                 :  * Microsoft's CP1251 (windows-1251)
                                 65                 :  * Alternativny Variant (MS-DOS CP866)
                                 66                 :  */
                                 67                 : 
                                 68                 : /* ISO-8859-5 to KOI8-R */
                                 69                 : static const unsigned char iso2koi[] = {
                                 70                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 71                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 72                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 73                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 74                 :     0x00, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 75                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 76                 :     0xE1, 0xE2, 0xF7, 0xE7, 0xE4, 0xE5, 0xF6, 0xFA,
                                 77                 :     0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0,
                                 78                 :     0xF2, 0xF3, 0xF4, 0xF5, 0xE6, 0xE8, 0xE3, 0xFE,
                                 79                 :     0xFB, 0xFD, 0xFF, 0xF9, 0xF8, 0xFC, 0xE0, 0xF1,
                                 80                 :     0xC1, 0xC2, 0xD7, 0xC7, 0xC4, 0xC5, 0xD6, 0xDA,
                                 81                 :     0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0,
                                 82                 :     0xD2, 0xD3, 0xD4, 0xD5, 0xC6, 0xC8, 0xC3, 0xDE,
                                 83                 :     0xDB, 0xDD, 0xDF, 0xD9, 0xD8, 0xDC, 0xC0, 0xD1,
                                 84                 :     0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 85                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                                 86                 : };
                                 87                 : 
                                 88                 : /* KOI8-R to ISO-8859-5 */
                                 89                 : static const unsigned char koi2iso[] = {
                                 90                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 91                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 92                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 93                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 94                 :     0x00, 0x00, 0x00, 0xF1, 0x00, 0x00, 0x00, 0x00,
                                 95                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 96                 :     0x00, 0x00, 0x00, 0xA1, 0x00, 0x00, 0x00, 0x00,
                                 97                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 98                 :     0xEE, 0xD0, 0xD1, 0xE6, 0xD4, 0xD5, 0xE4, 0xD3,
                                 99                 :     0xE5, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE,
                                100                 :     0xDF, 0xEF, 0xE0, 0xE1, 0xE2, 0xE3, 0xD6, 0xD2,
                                101                 :     0xEC, 0xEB, 0xD7, 0xE8, 0xED, 0xE9, 0xE7, 0xEA,
                                102                 :     0xCE, 0xB0, 0xB1, 0xC6, 0xB4, 0xB5, 0xC4, 0xB3,
                                103                 :     0xC5, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE,
                                104                 :     0xBF, 0xCF, 0xC0, 0xC1, 0xC2, 0xC3, 0xB6, 0xB2,
                                105                 :     0xCC, 0xCB, 0xB7, 0xC8, 0xCD, 0xC9, 0xC7, 0xCA
                                106                 : };
                                107                 : 
                                108                 : /* WIN1251 to KOI8-R */
                                109                 : static const unsigned char win12512koi[] = {
                                110                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                111                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                112                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                113                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                114                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0xBD, 0x00, 0x00,
                                115                 :     0xB3, 0x00, 0xB4, 0x00, 0x00, 0x00, 0x00, 0xB7,
                                116                 :     0x00, 0x00, 0xB6, 0xA6, 0xAD, 0x00, 0x00, 0x00,
                                117                 :     0xA3, 0x00, 0xA4, 0x00, 0x00, 0x00, 0x00, 0xA7,
                                118                 :     0xE1, 0xE2, 0xF7, 0xE7, 0xE4, 0xE5, 0xF6, 0xFA,
                                119                 :     0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0,
                                120                 :     0xF2, 0xF3, 0xF4, 0xF5, 0xE6, 0xE8, 0xE3, 0xFE,
                                121                 :     0xFB, 0xFD, 0xFF, 0xF9, 0xF8, 0xFC, 0xE0, 0xF1,
                                122                 :     0xC1, 0xC2, 0xD7, 0xC7, 0xC4, 0xC5, 0xD6, 0xDA,
                                123                 :     0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0,
                                124                 :     0xD2, 0xD3, 0xD4, 0xD5, 0xC6, 0xC8, 0xC3, 0xDE,
                                125                 :     0xDB, 0xDD, 0xDF, 0xD9, 0xD8, 0xDC, 0xC0, 0xD1
                                126                 : };
                                127                 : 
                                128                 : /* KOI8-R to WIN1251 */
                                129                 : static const unsigned char koi2win1251[] = {
                                130                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                131                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                132                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                133                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                134                 :     0x00, 0x00, 0x00, 0xB8, 0xBA, 0x00, 0xB3, 0xBF,
                                135                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00,
                                136                 :     0x00, 0x00, 0x00, 0xA8, 0xAA, 0x00, 0xB2, 0xAF,
                                137                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0xA5, 0x00, 0x00,
                                138                 :     0xFE, 0xE0, 0xE1, 0xF6, 0xE4, 0xE5, 0xF4, 0xE3,
                                139                 :     0xF5, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE,
                                140                 :     0xEF, 0xFF, 0xF0, 0xF1, 0xF2, 0xF3, 0xE6, 0xE2,
                                141                 :     0xFC, 0xFB, 0xE7, 0xF8, 0xFD, 0xF9, 0xF7, 0xFA,
                                142                 :     0xDE, 0xC0, 0xC1, 0xD6, 0xC4, 0xC5, 0xD4, 0xC3,
                                143                 :     0xD5, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE,
                                144                 :     0xCF, 0xDF, 0xD0, 0xD1, 0xD2, 0xD3, 0xC6, 0xC2,
                                145                 :     0xDC, 0xDB, 0xC7, 0xD8, 0xDD, 0xD9, 0xD7, 0xDA
                                146                 : };
                                147                 : 
                                148                 : /* WIN866 to KOI8-R */
                                149                 : static const unsigned char win8662koi[] = {
                                150                 :     0xE1, 0xE2, 0xF7, 0xE7, 0xE4, 0xE5, 0xF6, 0xFA,
                                151                 :     0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0,
                                152                 :     0xF2, 0xF3, 0xF4, 0xF5, 0xE6, 0xE8, 0xE3, 0xFE,
                                153                 :     0xFB, 0xFD, 0xFF, 0xF9, 0xF8, 0xFC, 0xE0, 0xF1,
                                154                 :     0xC1, 0xC2, 0xD7, 0xC7, 0xC4, 0xC5, 0xD6, 0xDA,
                                155                 :     0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0,
                                156                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                157                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0xBD, 0x00, 0x00,
                                158                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                159                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                160                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                161                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                162                 :     0xD2, 0xD3, 0xD4, 0xD5, 0xC6, 0xC8, 0xC3, 0xDE,
                                163                 :     0xDB, 0xDD, 0xDF, 0xD9, 0xD8, 0xDC, 0xC0, 0xD1,
                                164                 :     0xB3, 0xA3, 0xB4, 0xA4, 0xB7, 0xA7, 0x00, 0x00,
                                165                 :     0xB6, 0xA6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                                166                 : };
                                167                 : 
                                168                 : /* KOI8-R to WIN866 */
                                169                 : static const unsigned char koi2win866[] = {
                                170                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                171                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                172                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                173                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                174                 :     0x00, 0x00, 0x00, 0xF1, 0xF3, 0x00, 0xF9, 0xF5,
                                175                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x00, 0x00,
                                176                 :     0x00, 0x00, 0x00, 0xF0, 0xF2, 0x00, 0xF8, 0xF4,
                                177                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0xBD, 0x00, 0x00,
                                178                 :     0xEE, 0xA0, 0xA1, 0xE6, 0xA4, 0xA5, 0xE4, 0xA3,
                                179                 :     0xE5, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE,
                                180                 :     0xAF, 0xEF, 0xE0, 0xE1, 0xE2, 0xE3, 0xA6, 0xA2,
                                181                 :     0xEC, 0xEB, 0xA7, 0xE8, 0xED, 0xE9, 0xE7, 0xEA,
                                182                 :     0x9E, 0x80, 0x81, 0x96, 0x84, 0x85, 0x94, 0x83,
                                183                 :     0x95, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E,
                                184                 :     0x8F, 0x9F, 0x90, 0x91, 0x92, 0x93, 0x86, 0x82,
                                185                 :     0x9C, 0x9B, 0x87, 0x98, 0x9D, 0x99, 0x97, 0x9A
                                186                 : };
                                187                 : 
                                188                 : /* WIN866 to WIN1251 */
                                189                 : static const unsigned char win8662win1251[] = {
                                190                 :     0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
                                191                 :     0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
                                192                 :     0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
                                193                 :     0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
                                194                 :     0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
                                195                 :     0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
                                196                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                197                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0xA5, 0x00, 0x00,
                                198                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                199                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                200                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                201                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                202                 :     0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
                                203                 :     0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
                                204                 :     0xA8, 0xB8, 0xAA, 0xBA, 0xAF, 0xBF, 0x00, 0x00,
                                205                 :     0xB2, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                                206                 : };
                                207                 : 
                                208                 : /* WIN1251 to WIN866 */
                                209                 : static const unsigned char win12512win866[] = {
                                210                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                211                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                212                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                213                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                214                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0xBD, 0x00, 0x00,
                                215                 :     0xF0, 0x00, 0xF2, 0x00, 0x00, 0x00, 0x00, 0xF4,
                                216                 :     0x00, 0x00, 0xF8, 0xF9, 0xAD, 0x00, 0x00, 0x00,
                                217                 :     0xF1, 0x00, 0xF3, 0x00, 0x00, 0x00, 0x00, 0xF5,
                                218                 :     0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
                                219                 :     0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
                                220                 :     0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
                                221                 :     0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
                                222                 :     0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
                                223                 :     0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
                                224                 :     0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
                                225                 :     0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF
                                226                 : };
                                227                 : 
                                228                 : /* ISO-8859-5 to WIN1251 */
                                229                 : static const unsigned char iso2win1251[] = {
                                230                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                231                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                232                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                233                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                234                 :     0x00, 0xA8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                235                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                236                 :     0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
                                237                 :     0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
                                238                 :     0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
                                239                 :     0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
                                240                 :     0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
                                241                 :     0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
                                242                 :     0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
                                243                 :     0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
                                244                 :     0x00, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                245                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                                246                 : };
                                247                 : 
                                248                 : /* WIN1251 to ISO-8859-5 */
                                249                 : static const unsigned char win12512iso[] = {
                                250                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                251                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                252                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                253                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                254                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                255                 :     0xA1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                256                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                257                 :     0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                258                 :     0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
                                259                 :     0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
                                260                 :     0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
                                261                 :     0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
                                262                 :     0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
                                263                 :     0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
                                264                 :     0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
                                265                 :     0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF
                                266                 : };
                                267                 : 
                                268                 : /* ISO-8859-5 to WIN866 */
                                269                 : static const unsigned char iso2win866[] = {
                                270                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                271                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                272                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                273                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                274                 :     0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                275                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                276                 :     0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
                                277                 :     0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
                                278                 :     0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
                                279                 :     0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
                                280                 :     0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
                                281                 :     0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
                                282                 :     0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
                                283                 :     0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
                                284                 :     0x00, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                285                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                                286                 : };
                                287                 : 
                                288                 : /* WIN866 to ISO-8859-5 */
                                289                 : static const unsigned char win8662iso[] = {
                                290                 :     0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
                                291                 :     0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
                                292                 :     0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
                                293                 :     0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
                                294                 :     0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
                                295                 :     0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
                                296                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                297                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                298                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                299                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                300                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                301                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                302                 :     0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
                                303                 :     0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
                                304                 :     0xA1, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                305                 :     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                                306                 : };
                                307                 : 
                                308                 : 
                                309                 : Datum
 8426 ishii@postgresql.org      310               3 : koi8r_to_mic(PG_FUNCTION_ARGS)
                                311                 : {
 7289 tgl@sss.pgh.pa.us         312               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                313               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          314               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      315               3 :     bool        noError = PG_GETARG_BOOL(5);
                                316                 :     int         converted;
                                317                 : 
 6066 tgl@sss.pgh.pa.us         318               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_KOI8R, PG_MULE_INTERNAL);
                                319                 : 
 1621 heikki.linnakangas@i      320               3 :     converted = latin2mic(src, dest, len, LC_KOI8_R, PG_KOI8R, noError);
                                321                 : 
                                322               3 :     PG_RETURN_INT32(converted);
                                323                 : }
                                324                 : 
                                325                 : Datum
 8426 ishii@postgresql.org      326             165 : mic_to_koi8r(PG_FUNCTION_ARGS)
                                327                 : {
 7289 tgl@sss.pgh.pa.us         328             165 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                329             165 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          330             165 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      331             165 :     bool        noError = PG_GETARG_BOOL(5);
                                332                 :     int         converted;
                                333                 : 
 6066 tgl@sss.pgh.pa.us         334             165 :     CHECK_ENCODING_CONVERSION_ARGS(PG_MULE_INTERNAL, PG_KOI8R);
                                335                 : 
 1621 heikki.linnakangas@i      336             165 :     converted = mic2latin(src, dest, len, LC_KOI8_R, PG_KOI8R, noError);
                                337                 : 
                                338              93 :     PG_RETURN_INT32(converted);
                                339                 : }
                                340                 : 
                                341                 : Datum
 8426 ishii@postgresql.org      342              75 : iso_to_mic(PG_FUNCTION_ARGS)
                                343                 : {
 7289 tgl@sss.pgh.pa.us         344              75 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                345              75 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          346              75 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      347              75 :     bool        noError = PG_GETARG_BOOL(5);
                                348                 :     int         converted;
                                349                 : 
 6066 tgl@sss.pgh.pa.us         350              75 :     CHECK_ENCODING_CONVERSION_ARGS(PG_ISO_8859_5, PG_MULE_INTERNAL);
                                351                 : 
 1621 heikki.linnakangas@i      352              75 :     converted = latin2mic_with_table(src, dest, len, LC_KOI8_R, PG_ISO_8859_5, iso2koi, noError);
                                353                 : 
                                354              48 :     PG_RETURN_INT32(converted);
                                355                 : }
                                356                 : 
                                357                 : Datum
 8426 ishii@postgresql.org      358             165 : mic_to_iso(PG_FUNCTION_ARGS)
                                359                 : {
 7289 tgl@sss.pgh.pa.us         360             165 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                361             165 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          362             165 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      363             165 :     bool        noError = PG_GETARG_BOOL(5);
                                364                 :     int         converted;
                                365                 : 
 6066 tgl@sss.pgh.pa.us         366             165 :     CHECK_ENCODING_CONVERSION_ARGS(PG_MULE_INTERNAL, PG_ISO_8859_5);
                                367                 : 
 1621 heikki.linnakangas@i      368             165 :     converted = mic2latin_with_table(src, dest, len, LC_KOI8_R, PG_ISO_8859_5, koi2iso, noError);
                                369                 : 
                                370              93 :     PG_RETURN_INT32(converted);
                                371                 : }
                                372                 : 
                                373                 : Datum
 8426 ishii@postgresql.org      374               3 : win1251_to_mic(PG_FUNCTION_ARGS)
                                375                 : {
 7289 tgl@sss.pgh.pa.us         376               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                377               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          378               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      379               3 :     bool        noError = PG_GETARG_BOOL(5);
                                380                 :     int         converted;
                                381                 : 
 6066 tgl@sss.pgh.pa.us         382               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_WIN1251, PG_MULE_INTERNAL);
                                383                 : 
 1621 heikki.linnakangas@i      384               3 :     converted = latin2mic_with_table(src, dest, len, LC_KOI8_R, PG_WIN1251, win12512koi, noError);
                                385                 : 
                                386               3 :     PG_RETURN_INT32(converted);
                                387                 : }
                                388                 : 
                                389                 : Datum
 8426 ishii@postgresql.org      390               3 : mic_to_win1251(PG_FUNCTION_ARGS)
                                391                 : {
 7289 tgl@sss.pgh.pa.us         392               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                393               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          394               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      395               3 :     bool        noError = PG_GETARG_BOOL(5);
                                396                 :     int         converted;
                                397                 : 
 6066 tgl@sss.pgh.pa.us         398               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_MULE_INTERNAL, PG_WIN1251);
                                399                 : 
 1621 heikki.linnakangas@i      400               3 :     converted = mic2latin_with_table(src, dest, len, LC_KOI8_R, PG_WIN1251, koi2win1251, noError);
                                401                 : 
                                402               3 :     PG_RETURN_INT32(converted);
                                403                 : }
                                404                 : 
                                405                 : Datum
 7490 bruce@momjian.us          406               3 : win866_to_mic(PG_FUNCTION_ARGS)
                                407                 : {
 7289 tgl@sss.pgh.pa.us         408               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                409               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          410               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      411               3 :     bool        noError = PG_GETARG_BOOL(5);
                                412                 :     int         converted;
                                413                 : 
 6066 tgl@sss.pgh.pa.us         414               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_WIN866, PG_MULE_INTERNAL);
                                415                 : 
 1621 heikki.linnakangas@i      416               3 :     converted = latin2mic_with_table(src, dest, len, LC_KOI8_R, PG_WIN866, win8662koi, noError);
                                417                 : 
                                418               3 :     PG_RETURN_INT32(converted);
                                419                 : }
                                420                 : 
                                421                 : Datum
 7490 bruce@momjian.us          422               3 : mic_to_win866(PG_FUNCTION_ARGS)
                                423                 : {
 7289 tgl@sss.pgh.pa.us         424               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                425               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          426               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      427               3 :     bool        noError = PG_GETARG_BOOL(5);
                                428                 :     int         converted;
                                429                 : 
 6066 tgl@sss.pgh.pa.us         430               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_MULE_INTERNAL, PG_WIN866);
                                431                 : 
 1621 heikki.linnakangas@i      432               3 :     converted = mic2latin_with_table(src, dest, len, LC_KOI8_R, PG_WIN866, koi2win866, noError);
                                433                 : 
                                434               3 :     PG_RETURN_INT32(converted);
                                435                 : }
                                436                 : 
                                437                 : Datum
 8426 ishii@postgresql.org      438               3 : koi8r_to_win1251(PG_FUNCTION_ARGS)
                                439                 : {
 7289 tgl@sss.pgh.pa.us         440               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                441               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          442               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      443               3 :     bool        noError = PG_GETARG_BOOL(5);
                                444                 :     int         converted;
                                445                 : 
 6066 tgl@sss.pgh.pa.us         446               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_KOI8R, PG_WIN1251);
                                447                 : 
 1621 heikki.linnakangas@i      448               3 :     converted = local2local(src, dest, len, PG_KOI8R, PG_WIN1251, koi2win1251, noError);
                                449                 : 
                                450               3 :     PG_RETURN_INT32(converted);
                                451                 : }
                                452                 : 
                                453                 : Datum
 8426 ishii@postgresql.org      454               3 : win1251_to_koi8r(PG_FUNCTION_ARGS)
                                455                 : {
 7289 tgl@sss.pgh.pa.us         456               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                457               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          458               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      459               3 :     bool        noError = PG_GETARG_BOOL(5);
                                460                 :     int         converted;
                                461                 : 
 6066 tgl@sss.pgh.pa.us         462               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_WIN1251, PG_KOI8R);
                                463                 : 
 1621 heikki.linnakangas@i      464               3 :     converted = local2local(src, dest, len, PG_WIN1251, PG_KOI8R, win12512koi, noError);
                                465                 : 
                                466               3 :     PG_RETURN_INT32(converted);
                                467                 : }
                                468                 : 
                                469                 : Datum
 7490 bruce@momjian.us          470               3 : koi8r_to_win866(PG_FUNCTION_ARGS)
                                471                 : {
 7289 tgl@sss.pgh.pa.us         472               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                473               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          474               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      475               3 :     bool        noError = PG_GETARG_BOOL(5);
                                476                 :     int         converted;
                                477                 : 
 6066 tgl@sss.pgh.pa.us         478               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_KOI8R, PG_WIN866);
                                479                 : 
 1621 heikki.linnakangas@i      480               3 :     converted = local2local(src, dest, len, PG_KOI8R, PG_WIN866, koi2win866, noError);
                                481                 : 
                                482               3 :     PG_RETURN_INT32(converted);
                                483                 : }
                                484                 : 
                                485                 : Datum
 7490 bruce@momjian.us          486               3 : win866_to_koi8r(PG_FUNCTION_ARGS)
                                487                 : {
 7289 tgl@sss.pgh.pa.us         488               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                489               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          490               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      491               3 :     bool        noError = PG_GETARG_BOOL(5);
                                492                 :     int         converted;
                                493                 : 
 6066 tgl@sss.pgh.pa.us         494               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_WIN866, PG_KOI8R);
                                495                 : 
 1621 heikki.linnakangas@i      496               3 :     converted = local2local(src, dest, len, PG_WIN866, PG_KOI8R, win8662koi, noError);
                                497                 : 
                                498               3 :     PG_RETURN_INT32(converted);
                                499                 : }
                                500                 : 
                                501                 : Datum
 7490 bruce@momjian.us          502               3 : win866_to_win1251(PG_FUNCTION_ARGS)
                                503                 : {
 7289 tgl@sss.pgh.pa.us         504               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                505               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          506               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      507               3 :     bool        noError = PG_GETARG_BOOL(5);
                                508                 :     int         converted;
                                509                 : 
 6066 tgl@sss.pgh.pa.us         510               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_WIN866, PG_WIN1251);
                                511                 : 
 1621 heikki.linnakangas@i      512               3 :     converted = local2local(src, dest, len, PG_WIN866, PG_WIN1251, win8662win1251, noError);
                                513                 : 
                                514               3 :     PG_RETURN_INT32(converted);
                                515                 : }
                                516                 : 
                                517                 : Datum
 7490 bruce@momjian.us          518               3 : win1251_to_win866(PG_FUNCTION_ARGS)
                                519                 : {
 7289 tgl@sss.pgh.pa.us         520               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                521               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          522               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      523               3 :     bool        noError = PG_GETARG_BOOL(5);
                                524                 :     int         converted;
                                525                 : 
 6066 tgl@sss.pgh.pa.us         526               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_WIN1251, PG_WIN866);
                                527                 : 
 1621 heikki.linnakangas@i      528               3 :     converted = local2local(src, dest, len, PG_WIN1251, PG_WIN866, win12512win866, noError);
                                529                 : 
                                530               3 :     PG_RETURN_INT32(converted);
                                531                 : }
                                532                 : 
                                533                 : Datum
 8426 ishii@postgresql.org      534              75 : iso_to_koi8r(PG_FUNCTION_ARGS)
                                535                 : {
 7289 tgl@sss.pgh.pa.us         536              75 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                537              75 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          538              75 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      539              75 :     bool        noError = PG_GETARG_BOOL(5);
                                540                 :     int         converted;
                                541                 : 
 6066 tgl@sss.pgh.pa.us         542              75 :     CHECK_ENCODING_CONVERSION_ARGS(PG_ISO_8859_5, PG_KOI8R);
                                543                 : 
 1621 heikki.linnakangas@i      544              75 :     converted = local2local(src, dest, len, PG_ISO_8859_5, PG_KOI8R, iso2koi, noError);
                                545                 : 
                                546              48 :     PG_RETURN_INT32(converted);
                                547                 : }
                                548                 : 
                                549                 : Datum
 8426 ishii@postgresql.org      550               3 : koi8r_to_iso(PG_FUNCTION_ARGS)
                                551                 : {
 7289 tgl@sss.pgh.pa.us         552               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                553               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          554               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      555               3 :     bool        noError = PG_GETARG_BOOL(5);
                                556                 :     int         converted;
                                557                 : 
 6066 tgl@sss.pgh.pa.us         558               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_KOI8R, PG_ISO_8859_5);
                                559                 : 
 1621 heikki.linnakangas@i      560               3 :     converted = local2local(src, dest, len, PG_KOI8R, PG_ISO_8859_5, koi2iso, noError);
                                561                 : 
                                562               3 :     PG_RETURN_INT32(converted);
                                563                 : }
                                564                 : 
                                565                 : Datum
 8426 ishii@postgresql.org      566               3 : iso_to_win1251(PG_FUNCTION_ARGS)
                                567                 : {
 7289 tgl@sss.pgh.pa.us         568               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                569               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          570               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      571               3 :     bool        noError = PG_GETARG_BOOL(5);
                                572                 :     int         converted;
                                573                 : 
 6066 tgl@sss.pgh.pa.us         574               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_ISO_8859_5, PG_WIN1251);
                                575                 : 
 1621 heikki.linnakangas@i      576               3 :     converted = local2local(src, dest, len, PG_ISO_8859_5, PG_WIN1251, iso2win1251, noError);
                                577                 : 
                                578               3 :     PG_RETURN_INT32(converted);
                                579                 : }
                                580                 : 
                                581                 : Datum
 8426 ishii@postgresql.org      582               3 : win1251_to_iso(PG_FUNCTION_ARGS)
                                583                 : {
 7289 tgl@sss.pgh.pa.us         584               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                585               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          586               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      587               3 :     bool        noError = PG_GETARG_BOOL(5);
                                588                 :     int         converted;
                                589                 : 
 6066 tgl@sss.pgh.pa.us         590               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_WIN1251, PG_ISO_8859_5);
                                591                 : 
 1621 heikki.linnakangas@i      592               3 :     converted = local2local(src, dest, len, PG_WIN1251, PG_ISO_8859_5, win12512iso, noError);
                                593                 : 
                                594               3 :     PG_RETURN_INT32(converted);
                                595                 : }
                                596                 : 
                                597                 : Datum
 7490 bruce@momjian.us          598               3 : iso_to_win866(PG_FUNCTION_ARGS)
                                599                 : {
 7289 tgl@sss.pgh.pa.us         600               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                601               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          602               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      603               3 :     bool        noError = PG_GETARG_BOOL(5);
                                604                 :     int         converted;
                                605                 : 
 6066 tgl@sss.pgh.pa.us         606               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_ISO_8859_5, PG_WIN866);
                                607                 : 
 1621 heikki.linnakangas@i      608               3 :     converted = local2local(src, dest, len, PG_ISO_8859_5, PG_WIN866, iso2win866, noError);
                                609                 : 
                                610               3 :     PG_RETURN_INT32(converted);
                                611                 : }
                                612                 : 
                                613                 : Datum
 7490 bruce@momjian.us          614               3 : win866_to_iso(PG_FUNCTION_ARGS)
                                615                 : {
 7289 tgl@sss.pgh.pa.us         616               3 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
                                617               3 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
 8405 bruce@momjian.us          618               3 :     int         len = PG_GETARG_INT32(4);
 1621 heikki.linnakangas@i      619               3 :     bool        noError = PG_GETARG_BOOL(5);
                                620                 :     int         converted;
                                621                 : 
 6066 tgl@sss.pgh.pa.us         622               3 :     CHECK_ENCODING_CONVERSION_ARGS(PG_WIN866, PG_ISO_8859_5);
                                623                 : 
 1621 heikki.linnakangas@i      624               3 :     converted = local2local(src, dest, len, PG_WIN866, PG_ISO_8859_5, win8662iso, noError);
                                625                 : 
                                626               3 :     PG_RETURN_INT32(converted);
                                627                 : }
        

Generated by: LCOV version 2.4-beta