6
6
* Portions Copyright (c) 1994, Regents of the University of California
7
7
*
8
8
* IDENTIFICATION
9
- * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.16 2008/01/01 19:45:53 momjian Exp $
9
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.17 2008/03/20 10:30:04 heikki Exp $
10
10
*
11
11
*-------------------------------------------------------------------------
12
12
*/
@@ -301,6 +301,12 @@ win866_to_win1251(PG_FUNCTION_ARGS)
301
301
Assert (PG_GETARG_INT32 (1 )== PG_WIN1251 );
302
302
Assert (len >=0 );
303
303
304
+ /*
305
+ * Note: There are a few characters like the "Numero" sign that exist in
306
+ * all the other cyrillic encodings (win1251, ISO_8859-5 and cp866), but
307
+ * not in KOI8R. As we use MULE_INTERNAL/KOI8R as an intermediary, we
308
+ * will fail to convert those characters.
309
+ */
304
310
buf = palloc (len * ENCODING_GROWTH_RATE );
305
311
win8662mic (src ,buf ,len );
306
312
mic2win1251 (buf ,dest ,strlen ((char * )buf ));
@@ -321,6 +327,7 @@ win1251_to_win866(PG_FUNCTION_ARGS)
321
327
Assert (PG_GETARG_INT32 (1 )== PG_WIN866 );
322
328
Assert (len >=0 );
323
329
330
+ /* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
324
331
buf = palloc (len * ENCODING_GROWTH_RATE );
325
332
win12512mic (src ,buf ,len );
326
333
mic2win866 (buf ,dest ,strlen ((char * )buf ));
@@ -381,6 +388,7 @@ iso_to_win1251(PG_FUNCTION_ARGS)
381
388
Assert (PG_GETARG_INT32 (1 )== PG_WIN1251 );
382
389
Assert (len >=0 );
383
390
391
+ /* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
384
392
buf = palloc (len * ENCODING_GROWTH_RATE );
385
393
iso2mic (src ,buf ,len );
386
394
mic2win1251 (buf ,dest ,strlen ((char * )buf ));
@@ -401,6 +409,7 @@ win1251_to_iso(PG_FUNCTION_ARGS)
401
409
Assert (PG_GETARG_INT32 (1 )== PG_ISO_8859_5 );
402
410
Assert (len >=0 );
403
411
412
+ /* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
404
413
buf = palloc (len * ENCODING_GROWTH_RATE );
405
414
win12512mic (src ,buf ,len );
406
415
mic2iso (buf ,dest ,strlen ((char * )buf ));
@@ -421,6 +430,7 @@ iso_to_win866(PG_FUNCTION_ARGS)
421
430
Assert (PG_GETARG_INT32 (1 )== PG_WIN866 );
422
431
Assert (len >=0 );
423
432
433
+ /* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
424
434
buf = palloc (len * ENCODING_GROWTH_RATE );
425
435
iso2mic (src ,buf ,len );
426
436
mic2win866 (buf ,dest ,strlen ((char * )buf ));
@@ -441,6 +451,7 @@ win866_to_iso(PG_FUNCTION_ARGS)
441
451
Assert (PG_GETARG_INT32 (1 )== PG_ISO_8859_5 );
442
452
Assert (len >=0 );
443
453
454
+ /* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
444
455
buf = palloc (len * ENCODING_GROWTH_RATE );
445
456
win8662mic (src ,buf ,len );
446
457
mic2iso (buf ,dest ,strlen ((char * )buf ));
@@ -483,7 +494,7 @@ iso2mic(const unsigned char *l, unsigned char *p, int len)
483
494
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
484
495
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
485
496
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
486
- 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
497
+ 0x00 ,0xb3 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
487
498
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
488
499
0xe1 ,0xe2 ,0xf7 ,0xe7 ,0xe4 ,0xe5 ,0xf6 ,0xfa ,
489
500
0xe9 ,0xea ,0xeb ,0xec ,0xed ,0xee ,0xef ,0xf0 ,
@@ -493,7 +504,7 @@ iso2mic(const unsigned char *l, unsigned char *p, int len)
493
504
0xc9 ,0xca ,0xcb ,0xcc ,0xcd ,0xce ,0xcf ,0xd0 ,
494
505
0xd2 ,0xd3 ,0xd4 ,0xd5 ,0xc6 ,0xc8 ,0xc3 ,0xde ,
495
506
0xdb ,0xdd ,0xdf ,0xd9 ,0xd8 ,0xdc ,0xc0 ,0xd1 ,
496
- 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
507
+ 0x00 ,0xa3 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
497
508
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00
498
509
};
499
510
@@ -509,9 +520,9 @@ mic2iso(const unsigned char *mic, unsigned char *p, int len)
509
520
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
510
521
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
511
522
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
523
+ 0x00 ,0x00 ,0x00 ,0xf1 ,0x00 ,0x00 ,0x00 ,0x00 ,
512
524
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
513
- 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
514
- 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
525
+ 0x00 ,0x00 ,0x00 ,0xa1 ,0x00 ,0x00 ,0x00 ,0x00 ,
515
526
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,
516
527
0xee ,0xd0 ,0xd1 ,0xe6 ,0xd4 ,0xd5 ,0xe4 ,0xd3 ,
517
528
0xe5 ,0xd8 ,0xd9 ,0xda ,0xdb ,0xdc ,0xdd ,0xde ,