/* iscii-to-unicode.c * * Authors : Sandeep Patnaik (patnaik@students.iiit.net) * Sunil Mohan Adapa (sunilmohanadapa@postmark.net) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #define uint16 unsigned short int unicode[] = { // Start is 0xA1 mapped to 0x0901 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 14, 15, 16, 13, 18, 19, 20, 17, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 95, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 62, 63, 64, 65, 66, 67, 70, 71, 72, 69, 74, 75, 76, 73, 77, 60,100, 0, 0, 0, 0, 0, 0, 102,103,104,105,106,107,108,109,110,111, 0, 0, 0, 0 }; int nukta[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 0, 12, 97, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 88, 89, 90, 0, 0, 0, 0, 91, 0, 0, 0, 0, 92, 93, 0, 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 0, 99, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint16 *iscii_to_unicode (unsigned char *iscii_string) { int i=0,j=0; static uint16 *unicode_string = NULL; if (unicode_string) free (unicode_string); unicode_string = (uint16 *) malloc (sizeof (uint16) * (strlen (iscii_string) + 1)); while (iscii_string[i]) { // The special nukta case if (iscii_string[i] >= 0xA1 && iscii_string[i] <= 0xFE && iscii_string[i+1] == 0xE9) { unicode_string [j++] = 0x0900 | nukta [iscii_string[i]]; i+=2; continue; } // The other ISCII case if (iscii_string[i] >= 0xA1 && iscii_string[i] <= 0xFE) { unicode_string [j++] = 0x0900 | unicode [iscii_string[i] - 0xA1]; i++; continue; } // ASCII unicode_string [j++] = iscii_string[i++]; } unicode_string [j] = 0; return unicode_string; }