Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

latin1utf16.cpp

00001 /******************************************************************************
00002  *
00003  * Latin1UTF16 -        SWFilter decendant to convert a Latin-1 character to UTF-16
00004  *
00005  */
00006 
00007 
00008 #include <stdlib.h>
00009 #include <stdio.h>
00010 #include <latin1utf16.h>
00011 
00012 Latin1UTF16::Latin1UTF16() {
00013 }
00014 
00015 
00016 char Latin1UTF16::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
00017 {
00018     unsigned char *from;
00019     unsigned short *to;
00020     int len;
00021     
00022     len = strlen(text) + 1;                                             // shift string to right of buffer
00023     if (len < maxlen) {
00024       memmove(&text[maxlen - len], text, len);
00025       from = (unsigned char*)&text[maxlen - len];
00026     }
00027     else        
00028       from = (unsigned char*)text;
00029     // -------------------------------
00030     
00031     for (to = (unsigned short*)text; *from; from++) {
00032         switch (*from) {
00033         case 0x80: // '€'
00034                 *to++ = 0x20AC;
00035                 break;
00036         case 0x82: // '‚'
00037                 *to++ = 0x201A;
00038                 break;
00039         case 0x83: // 'ƒ'
00040                 *to++ = 0x0192;
00041                 break;
00042         case 0x84: // '„'
00043                 *to++ = 0x201E;
00044                 break;
00045         case 0x85: // '…'
00046                 *to++ = 0x2026;
00047                 break;
00048         case 0x86: // '†'
00049                 *to++ = 0x2020;
00050                 break;
00051         case 0x87: // '‡'
00052                 *to++ = 0x2021;
00053                 break;
00054         case 0x88: // 'ˆ'
00055                 *to++ = 0x02C6;
00056                 break;
00057         case 0x89: // '‰'
00058                 *to++ = 0x2030;
00059                 break;
00060         case 0x8A: // 'Š'
00061                 *to++ = 0x0160;
00062                 break;
00063         case 0x8B: // '‹'
00064                 *to++ = 0x2039;
00065                 break;
00066         case 0x8C: // 'Œ'
00067                 *to++ = 0x0152;
00068                 break;
00069         case 0x8E: // 'Ž'
00070                 *to++ = 0x017D;
00071                 break;
00072         case 0x91: // '‘'
00073                 *to++ = 0x2018;
00074                 break;
00075         case 0x92: // '’'
00076                 *to++ = 0x2019;
00077                 break;
00078         case 0x93: // '“'
00079                 *to++ = 0x201C;
00080                 break;
00081         case 0x94: // '”'
00082                 *to++ = 0x201D;
00083                 break;
00084         case 0x95: // '•'
00085                 *to++ = 0x2022;
00086                 break;
00087         case 0x96: // '–'
00088                 *to++ = 0x2013;
00089                 break;
00090         case 0x97: // '—'
00091                 *to++ = 0x2014;
00092                 break;
00093         case 0x98: // '˜'
00094                 *to++ = 0x02DC;
00095                 break;
00096         case 0x99: // '™'
00097                 *to++ = 0x2122;
00098                 break;
00099         case 0x9A: // 'š'
00100                 *to++ = 0x0161;
00101                 break;
00102         case 0x9B: // '›'
00103                 *to++ = 0x203A;
00104                 break;
00105         case 0x9C: // 'œ'
00106                 *to++ = 0x0153;
00107                 break;
00108         case 0x9E: // 'ž'
00109                 *to++ = 0x017E;
00110                 break;
00111         case 0x9F: // 'Ÿ'
00112                 *to++ = 0x0178;
00113                 break;
00114         default:
00115                *to++ = (unsigned short)*from;
00116         }
00117     }
00118     *to = 0;
00119     return 0;
00120 }

Generated on Thu Jun 20 22:12:59 2002 for The Sword Project by doxygen1.2.15