Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
chartoname.cpp
Go to the documentation of this file.
1 /**************************************************************************
2 ** Licensed under the Apache License, Version 2.0 (the "License");
3 ** you may not use this file except in compliance with the License.
4 ** You may obtain a copy of the License at
5 ** http://www.apache.org/licenses/LICENSE-2.0
6 ** Unless required by applicable law or agreed to in writing, software
7 ** distributed under the License is distributed on an "AS IS" BASIS,
8 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 ** See the License for the specific language governing permissions and
10 ** limitations under the License.
11 **************************************************************************/
12 #include <string.h>
13 #include <ctype.h>
14
15 /*chartoname(name,c,dir) converts c into a useful filename*/
16 void chartoname(register char *name, /*result */
17 char c, /*char to convert */
18 const char *dir) { /*directory to use */
19 char file[3]; /*filename */
20 int index; /*index of namelist */
21 static const char *namelist[] = {
22 "!bang",
23 "\"doubleq",
24 "#hash",
25 "$dollar",
26 "%percent",
27 "&and",
28 "'quote",
29 "(lround",
30 ")rround",
31 "*asterisk",
32 "+plus",
33 ",comma",
34 "-minus",
35 ".dot",
36 "/slash",
37 ":colon",
38 ";semic",
39 "<less",
40 "=equal",
41 ">greater",
42 "?question",
43 "@at",
44 "[lsquare",
45 "\\backsl",
46 "]rsquare",
47 "^uparr",
48 "_unders",
49 "`grave",
50 "{lbrace",
51 "|bar",
52 "}rbrace",
53 "~tilde"
54 };
55
56 strcpy(name, dir); /*add specific directory */
57 for (index = 0; index < sizeof namelist / sizeof (char *)
58 && c != namelist[index][0]; index++);
59 if (index < sizeof namelist / sizeof (char *))
60 /*add text name */
61 strcat (name, &namelist[index][1]);
62 else {
63 if (isupper (c)) {
64 file[0] = 'c'; /*direct a-z or A-Z */
65 file[1] = c; /*direct a-z or A-Z */
66 file[2] = '\0';
67 }
68 else {
69 file[0] = c; /*direct a-z or A-Z */
70 file[1] = '\0';
71 }
72 strcat(name, file); /*append filename */
73 }
74 }