How do you show the extended ascii table on C using Xcode?

760 views Asked by At

I'm programming on Xcode in C language. I've tried using a for loop to see which characters would I get for each number like this:

    printf("Lista of caracteres: \n");
    for (i=0;i<256;i++){
        printf("Caracter %d: %c \n", i, i);
    }

but starting from 128, I'm getting different results from the regular ascii table.


Lista de caracteres: 
Caracter 0: � 
Caracter 1:  
Caracter 2:  
Caracter 3:  
Caracter 4:  
Caracter 5:  
Caracter 6:  
Caracter 7:  
Caracter 8:  
Caracter 9:      
Caracter 10: 

Caracter 11:  
Caracter 12:  
Caracter 13: 

Caracter 14:  
Caracter 15:  
Caracter 16:  
Caracter 17:  
Caracter 18:  
Caracter 19:  
Caracter 20:  
Caracter 21:  
Caracter 22:  
Caracter 23:  
Caracter 24:  
Caracter 25:  
Caracter 26:  
Caracter 27:  
Caracter 28:  
Caracter 29:  
Caracter 30:  
Caracter 31:  
Caracter 32:   
Caracter 33: ! 
Caracter 34: " 
Caracter 35: # 
Caracter 36: $ 
Caracter 37: % 
Caracter 38: & 
Caracter 39: ' 
Caracter 40: ( 
Caracter 41: ) 
Caracter 42: * 
Caracter 43: + 
Caracter 44: , 
Caracter 45: - 
Caracter 46: . 
Caracter 47: / 
Caracter 48: 0 
Caracter 49: 1 
Caracter 50: 2 
Caracter 51: 3 
Caracter 52: 4 
Caracter 53: 5 
Caracter 54: 6 
Caracter 55: 7 
Caracter 56: 8 
Caracter 57: 9 
Caracter 58: : 
Caracter 59: ; 
Caracter 60: < 
Caracter 61: = 
Caracter 62: > 
Caracter 63: ? 
Caracter 64: @ 
Caracter 65: A 
Caracter 66: B 
Caracter 67: C 
Caracter 68: D 
Caracter 69: E 
Caracter 70: F 
Caracter 71: G 
Caracter 72: H 
Caracter 73: I 
Caracter 74: J 
Caracter 75: K 
Caracter 76: L 
Caracter 77: M 
Caracter 78: N 
Caracter 79: O 
Caracter 80: P 
Caracter 81: Q 
Caracter 82: R 
Caracter 83: S 
Caracter 84: T 
Caracter 85: U 
Caracter 86: V 
Caracter 87: W 
Caracter 88: X 
Caracter 89: Y 
Caracter 90: Z 
Caracter 91: [ 
Caracter 92: \ 
Caracter 93: ] 
Caracter 94: ^ 
Caracter 95: _ 
Caracter 96: ` 
Caracter 97: a 
Caracter 98: b 
Caracter 99: c 
Caracter 100: d 
Caracter 101: e 
Caracter 102: f 
Caracter 103: g 
Caracter 104: h 
Caracter 105: i 
Caracter 106: j 
Caracter 107: k 
Caracter 108: l 
Caracter 109: m 
Caracter 110: n 
Caracter 111: o 
Caracter 112: p 
Caracter 113: q 
Caracter 114: r 
Caracter 115: s 
Caracter 116: t 
Caracter 117: u 
Caracter 118: v 
Caracter 119: w 
Caracter 120: x 
Caracter 121: y 
Caracter 122: z 
Caracter 123: { 
Caracter 124: | 
Caracter 125: } 
Caracter 126: ~ 
Caracter 127:  
Caracter 128: \200 
Caracter 129: \201 
Caracter 130: \202 
Caracter 131: \203 
Caracter 132: \204 
Caracter 133: \205 
Caracter 134: \206 
Caracter 135: \207 
Caracter 136: \210 
Caracter 137: \211 
Caracter 138: \212 
Caracter 139: \213 
Caracter 140: \214 
Caracter 141: \215 
Caracter 142: \216 
Caracter 143: \217 
Caracter 144: \220 
Caracter 145: \221 
Caracter 146: \222 
Caracter 147: \223 
Caracter 148: \224 
Caracter 149: \225 
Caracter 150: \226 
Caracter 151: \227 
Caracter 152: \230 
Caracter 153: \231 
Caracter 154: \232 
Caracter 155: \233 
Caracter 156: \234 
Caracter 157: \235 
Caracter 158: \236 
Caracter 159: \237 
Caracter 160: \240 
Caracter 161: \241 
Caracter 162: \242 
Caracter 163: \243 
Caracter 164: \244 
Caracter 165: \245 
Caracter 166: \246 
Caracter 167: \247 
Caracter 168: \250 
Caracter 169: \251 
Caracter 170: \252 
Caracter 171: \253 
Caracter 172: \254 
Caracter 173: \255 
Caracter 174: \256 
Caracter 175: \257 
Caracter 176: \260 
Caracter 177: \261 
Caracter 178: \262 
Caracter 179: \263 
Caracter 180: \264 
Caracter 181: \265 
Caracter 182: \266 
Caracter 183: \267 
Caracter 184: \270 
Caracter 185: \271 
Caracter 186: \272 
Caracter 187: \273 
Caracter 188: \274 
Caracter 189: \275 
Caracter 190: \276 
Caracter 191: \277 
Caracter 192: \300 
Caracter 193: \301 
Caracter 194: \302 
Caracter 195: \303 
Caracter 196: \304 
Caracter 197: \305 
Caracter 198: \306 
Caracter 199: \307 
Caracter 200: \310 
Caracter 201: \311 
Caracter 202: \312 
Caracter 203: \313 
Caracter 204: \314 
Caracter 205: \315 
Caracter 206: \316 
Caracter 207: \317 
Caracter 208: \320 
Caracter 209: \321 
Caracter 210: \322 
Caracter 211: \323 
Caracter 212: \324 
Caracter 213: \325 
Caracter 214: \326 
Caracter 215: \327 
Caracter 216: \330 
Caracter 217: \331 
Caracter 218: \332 
Caracter 219: \333 
Caracter 220: \334 
Caracter 221: \335 
Caracter 222: \336 
Caracter 223: \337 
Caracter 224: \340 
Caracter 225: \341 
Caracter 226: \342 
Caracter 227: \343 
Caracter 228: \344 
Caracter 229: \345 
Caracter 230: \346 
Caracter 231: \347 
Caracter 232: \350 
Caracter 233: \351 
Caracter 234: \352 
Caracter 235: \353 
Caracter 236: \354 
Caracter 237: \355 
Caracter 238: \356 
Caracter 239: \357 
Caracter 240: \360 
Caracter 241: \361 
Caracter 242: \362 
Caracter 243: \363 
Caracter 244: \364 
Caracter 245: \365 
Caracter 246: \366 
Caracter 247: \367 
Caracter 248: \370 
Caracter 249: \371 
Caracter 250: \372 
Caracter 251: \373 
Caracter 252: \374 
Caracter 253: \375 
Caracter 254: \376 
Caracter 255: \377 

What can I do to get the character "é" (130 on ascii table), for example?

I just now realised I'm asking how can I use the extended ascii table on C language using Xcode.

1

There are 1 answers

0
Asperi On

You have to use wprintf instead of printf and set the locale as shown below:

#include <stdio.h>
#include <wchar.h>
#include <locale.h>

int main(void) {
    setlocale( LC_ALL, "en_US.UTF-8" );
    for (wchar_t i=0; i<=255; i++) {
        wprintf( L"Caracter %d: %lc\n", i, i);
    }

    return 0;
}