classify/chartoname.cpp

Go to the documentation of this file.
00001 
00015 #include <string.h>
00016 #include <ctype.h>
00017 
00021 void chartoname(register char *name,  /*result */
00022                 char c,               /*char to convert */
00023                 const char *dir) {    /*directory to use */
00024   char file[3];                  /*filename */
00025   int index;                     /*index of namelist */
00026   static const char *namelist[] = {
00027     "!bang",
00028     "\"doubleq",
00029     "#hash",
00030     "$dollar",
00031     "%percent",
00032     "&and",
00033     "'quote",
00034     "(lround",
00035     ")rround",
00036     "*asterisk",
00037     "+plus",
00038     ",comma",
00039     "-minus",
00040     ".dot",
00041     "/slash",
00042     ":colon",
00043     ";semic",
00044     "<less",
00045     "=equal",
00046     ">greater",
00047     "?question",
00048     "@at",
00049     "[lsquare",
00050     "\\backsl",
00051     "]rsquare",
00052     "^uparr",
00053     "_unders",
00054     "`grave",
00055     "{lbrace",
00056     "|bar",
00057     "}rbrace",
00058     "~tilde"
00059   };
00060 
00061   strcpy(name, dir);  /*add specific directory */
00062   for (index = 0; index < sizeof namelist / sizeof (char *)
00063     && c != namelist[index][0]; index++);
00064   if (index < sizeof namelist / sizeof (char *))
00065                                  /*add text name */
00066     strcat (name, &namelist[index][1]);
00067   else {
00068     if (isupper (c)) {
00069       file[0] = 'c';             /*direct a-z or A-Z */
00070       file[1] = c;               /*direct a-z or A-Z */
00071       file[2] = '\0';
00072     }
00073     else {
00074       file[0] = c;               /*direct a-z or A-Z */
00075       file[1] = '\0';
00076     }
00077     strcat(name, file);  /*append filename */
00078   }
00079 }

Generated on Wed Feb 28 19:49:09 2007 for Tesseract by  doxygen 1.5.1