charcnv.c: Added codepage 866 support onto the file system. Patch
[samba.git] / source / lib / charcnv.c
index e1a7ac01db522c0727cbabca599fbfab95611a11..f5d28baee46e81ee77cdc525e85644fb480ff7a8 100644 (file)
@@ -98,6 +98,62 @@ update_map("\257\275\261\245\346\206\352\251\263\210\361\344\363\242\266\230");
 update_map("\274\253\277\276");
 }
 
+/* Init for russian language (iso8859-5) */
+
+/* Added by Max Khon <max@iclub.nsu.ru> */
+
+static void init_iso8859_5()
+{
+  int i;
+  if (!mapsinited) initmaps();
+
+  /* Do not map undefined characters to some accidental code */
+  for (i = 128; i < 256; i++) 
+  {
+     unix2dos[i] = CTRLZ;
+     dos2unix[i] = CTRLZ;
+  }
+
+/* MSDOS Code Page 866 -> ISO8859-5 */
+update_map("\200\260\201\261\202\262\203\263\204\264\205\265\206\266\207\267");
+update_map("\210\270\211\271\212\272\213\273\214\274\215\275\216\276\217\277");
+update_map("\220\300\221\301\222\302\223\303\224\304\225\305\226\306\227\307");
+update_map("\230\310\231\311\232\312\233\313\234\314\235\315\236\316\237\317");
+update_map("\240\320\241\321\242\322\243\323\244\324\245\325\246\326\247\327");
+update_map("\250\330\251\331\252\332\253\333\254\334\255\335\256\336\257\337");
+update_map("\340\340\341\341\342\342\343\343\344\344\345\345\346\346\347\347");
+update_map("\350\350\351\351\352\352\353\353\354\354\355\355\356\356\357\357");
+update_map("\360\241\361\361\362\244\363\364\364\247\365\367\366\256\367\376");
+update_map("\374\360\377\240");
+}
+
+/* Init for russian language (koi8) */
+
+static void init_koi8_r()
+{
+  if (!mapsinited) initmaps();
+
+  /* There aren't undefined characters between 128 and 255 */
+
+/* MSDOS Code Page 866 -> KOI8-R */
+update_map("\200\304\201\263\202\332\203\277\204\300\205\331\206\303\207\264");
+update_map("\210\302\211\301\212\305\213\337\214\334\215\333\216\335\217\336");
+update_map("\220\260\221\261\222\262\223\364\224\376\225\371\226\373\227\367");
+update_map("\230\363\231\362\232\377\233\365\234\370\235\375\236\372\237\366");
+update_map("\240\315\241\272\242\325\243\361\244\326\245\311\246\270\247\267");
+update_map("\250\273\251\324\252\323\253\310\254\276\255\275\256\274\257\306");
+update_map("\260\307\261\314\262\265\263\360\264\266\265\271\266\321\267\322");
+update_map("\270\313\271\317\272\320\273\312\274\330\275\327\276\316\277\374");
+update_map("\300\356\301\240\302\241\303\346\304\244\305\245\306\344\307\243");
+update_map("\310\345\311\250\312\251\313\252\314\253\315\254\316\255\317\256");
+update_map("\320\257\321\357\322\340\323\341\324\342\325\343\326\246\327\242");
+update_map("\330\354\331\353\332\247\333\350\334\355\335\351\336\347\337\352");
+update_map("\340\236\341\200\342\201\343\226\344\204\345\205\346\224\347\203");
+update_map("\350\225\351\210\352\211\353\212\354\213\355\214\356\215\357\216");
+update_map("\360\217\361\237\362\220\363\221\364\222\365\223\366\206\367\202");
+update_map("\370\234\371\233\372\207\373\230\374\235\375\231\376\227\377\232");
+}
+
 /*
  * Convert unix to dos
  */
@@ -156,6 +212,10 @@ void interpret_character_set(char *str)
         init_iso8859_1();
     } else if (strequal (str, "iso8859-2")) {
         init_iso8859_2();
+    } else if (strequal (str, "iso8859-5")) {
+        init_iso8859_5();
+    } else if (strequal (str, "koi8-r")) {
+        init_koi8_r();
     } else {
         DEBUG(0,("unrecognized character set\n"));
     }