]> git.saurik.com Git - apple/libc.git/blob - internat/NXToAscii.c
Libc-391.tar.gz
[apple/libc.git] / internat / NXToAscii.c
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 * Copyright 1990, NeXT, Inc.
25 */
26
27 #include "NXCType.h"
28 #define FIXSIGNEDCHAR(i) if ((i & 0xFFFFFF80) == 0xFFFFFF80) i &= 0x000000FF
29
30 unsigned char *
31 NXToAscii(c)
32 unsigned int c;
33 {
34 static unsigned char woops[] = " ";
35
36 FIXSIGNEDCHAR(c);
37 if (c < 128) { /* handle stuff already ASCII */
38 woops[0] = c;
39 return (unsigned char *) woops;
40 }
41 switch (c) {
42 case 128: /* Figspace */
43 return (unsigned char *) " ";
44 case 129: /* Agrave */
45 case 130: /* Aacute */
46 case 131: /* Acircumflex */
47 case 132: /* Atilde */
48 case 133: /* Adieresis */
49 case 134: /* Aring */
50 return (unsigned char *) "A";
51 case 135: /* Ccedilla */
52 return (unsigned char *) "C";
53 case 136: /* Egrave */
54 case 137: /* Eacute */
55 case 138: /* Ecircumflex */
56 case 139: /* Edieresis */
57 return (unsigned char *) "E";
58 case 140: /* Igrave */
59 case 141: /* Iacute */
60 case 142: /* Icircumflex */
61 case 143: /* Idieresis */
62 return (unsigned char *) "I";
63 case 145: /* Ntilde */
64 return (unsigned char *) "N";
65 case 146: /* Ograve */
66 case 147: /* Oacute */
67 case 148: /* Ocircumflex */
68 case 149: /* Otilde */
69 case 150: /* Odieresis */
70 case 233: /* Oslash */
71 return (unsigned char *) "O";
72 case 151: /* Ugrave */
73 case 152: /* Uacute */
74 case 153: /* Ucircumflex */
75 case 154: /* Udieresis */
76 return (unsigned char *) "U";
77 case 155: /* Yacute */
78 return (unsigned char *) "Y";
79 case 230: /* eth */
80 case 144: /* Eth */
81 return (unsigned char *) "TH";
82 case 156: /* Thorn */
83 case 252: /* thorn */
84 return (unsigned char *) "th";
85
86 case 174: /* fi */
87 return (unsigned char *) "fi";
88 case 175: /* fl */
89 return (unsigned char *) "fl";
90
91 case 213: /* agrave */
92 case 214: /* aacute */
93 case 215: /* acircumflex */
94 case 216: /* atilde */
95 case 217: /* adieresis */
96 case 218: /* aring */
97 return (unsigned char *) "a";
98 case 219: /* ccedilla */
99 return (unsigned char *) "c";
100 case 220: /* egrave */
101 case 221: /* eacute */
102 case 222: /* ecircumflex */
103 case 223: /* edieresis */
104 return (unsigned char *) "e";
105 case 225: /* AE */
106 return (unsigned char *) "AE";
107 case 224: /* igrave */
108 case 226: /* iacute */
109 case 228: /* icircumflex */
110 case 229: /* idieresis */
111 return (unsigned char *) "i";
112 case 231: /* ntilde */
113 return (unsigned char *) "n";
114 case 232: /* Lslash */
115 return (unsigned char *) "L";
116 case 234: /* OE */
117 return (unsigned char *) "OE";
118 case 236: /* ograve */
119 case 237: /* oacute */
120 case 238: /* ocircumflex */
121 case 239: /* otilde */
122 case 240: /* odieresis */
123 case 249: /* oslash */
124 return (unsigned char *) "o";
125 case 241: /* ae */
126 return (unsigned char *) "ae";
127 case 242: /* ugrave */
128 case 243: /* uacute */
129 case 244: /* ucircumflex */
130 case 246: /* udieresis */
131 return (unsigned char *) "u";
132 case 245: /* dotlessi */
133 return (unsigned char *) "i";
134 case 247: /* yacute */
135 case 253: /* ydieresis */
136 return (unsigned char *) "y";
137 case 248: /* lslash */
138 return (unsigned char *) "l";
139 case 250: /* oe */
140 return (unsigned char *) "oe";
141 case 251: /* germandbls */
142 return (unsigned char *) "ss";
143 /*
144 * non-letter cases:
145 */
146 case 158: /* multiply */
147 return (unsigned char *) "x";
148 case 159: /* divide */
149 return (unsigned char *) "/";
150
151 case 161: /* exclamdown */
152 return (unsigned char *) "!";
153 case 169: /* quotesingle */
154 return (unsigned char *) "'";
155
156 case 170: /* quotedblleft */
157 case 186: /* quotedblright */
158 case 185: /* quotedblbase */
159 return (unsigned char *) "\"";
160 case 171: /* guillemotleft */
161 return (unsigned char *) "<<";
162 case 187: /* guillemotright */
163 return (unsigned char *) ">>";
164 case 184: /* quotesinglbase */
165 return (unsigned char *) "'";
166 case 172: /* guilsinglleft */
167 return (unsigned char *) "<";
168 case 173: /* guilsinglright */
169 return (unsigned char *) ">";
170 case 180: /* periodcentered */
171 return (unsigned char *) ".";
172 case 181: /* brokenbar */
173 return (unsigned char *) "|";
174 case 183: /* bullet */
175 return (unsigned char *) "*";
176 case 188: /* ellipsis */
177 return (unsigned char *) "...";
178 case 191: /* questiondown */
179 return (unsigned char *) "?";
180 case 192: /* onesuperior */
181 return (unsigned char *) "1";
182 case 201: /* twosuperior */
183 return (unsigned char *) "2";
184 case 204: /* threesuperior */
185 return (unsigned char *) "3";
186 case 208: /* emdash */
187 return (unsigned char *) "--";
188 case 209: /* plusminus */
189 return (unsigned char *) "+-";
190 case 210: /* onequarter */
191 return (unsigned char *) "1/4";
192 case 211: /* onehalf */
193 return (unsigned char *) "1/2";
194 case 212: /* threequarters */
195 return (unsigned char *) "3/4";
196 case 227: /* ordfeminine */
197 return (unsigned char *) "a";
198 case 235: /* ordmasculine */
199 return (unsigned char *) "o";
200 case 157: /* mu */
201 return (unsigned char *) "u";
202 case 160: /* copyright */
203 return (unsigned char *) "(C)";
204 case 163: /* sterling */
205 return (unsigned char *) "L";
206 case 164: /* fraction */
207 return (unsigned char *) "/";
208 case 165: /* yen */
209 return (unsigned char *) "Y";
210 case 166: /* florin */
211 return (unsigned char *) "f";
212 case 176: /* registered */
213 return (unsigned char *) "(R)";
214 case 190: /* logicalnot */
215 case 177: /* endash */
216 return (unsigned char *) "-";
217 case 178: /* dagger */
218 return (unsigned char *) "+";
219 case 179: /* daggerdbl */
220 return (unsigned char *) "++";
221 case 189: /* perthousand */
222 return (unsigned char *) "0/00";
223 case 193: /* grave */
224 return (unsigned char *) "`";
225 case 194: /* acute */
226 return (unsigned char *) "'";
227 case 195: /* circumflex */
228 return (unsigned char *) "^";
229 case 196: /* tilde */
230 return (unsigned char *) "~";
231
232 /*
233 * Default & fallback cases:
234 */
235 case 162: /* cent */
236 case 167: /* section */
237 case 168: /* currency */
238 case 182: /* paragraph */
239 case 197: /* macron */
240 case 198: /* breve */
241 case 199: /* dotaccent */
242 case 200: /* dieresis */
243 case 202: /* ring */
244 case 203: /* cedilla */
245 case 205: /* hungarumlaut */
246 case 206: /* ogonek */
247 case 207: /* caron */
248 default:
249 return (unsigned char *) "_";
250 }
251 }