bash printing extended ASCII characters
I'm trying to print ? ? ? and other extended ascii character in bash using printf, but they don't seem to be regonised. The syntax I'm using is
printf "\###" where ### is the octal value for the character. Does anyone know if extended ascii is supported in bash and if so how to print the characters to the screen? Thanks |
That depends a little of the font used in terminal (what do you call extended ascii ?)
Try (in hexa) : echo -e "\xA9" and in octal : echo -e "\0251" |
I've been programming for a few years and I never knew that 'extended ascii' was so ambiguous, but now I've done some reading I realise there is no such thing.
When I say extended ascii, I guess I mean IBM DOS extended ascii. Have a look at http://www.lookuptables.com/ there is some 'extended ascii' at the bottom. |
Lol, I see... For me this is just ascii (but I don't program for a few years, just the last one)
I would say again that the display of these chars depends of the terminal font, eg if the char won't display, it may means that this char is not built in the font. |
I've been reading something about codepage. That might have something to do with it. bash has something there about 127, I'm just doing a script to find out what it is, I'll let you know.
|
Well nothing too good. Below is a list of the ascii code outputs through printf from 0 to 400. The left column is the octal code, the right is the output. Hope this helps someone out, because it helped me squat ;)
0 1 2 3 4 5 6 7 8 \8 9 \9 10 11 12 13 14 15 16 17 18 8 19 9 20 21 22 23 24 25 26 27 28 8 29 9 30 31 32 33 34 35 36 37 38 8 39 9 40 41 ! 42 " 43 # 44 $ 45 % 46 & 47 ' 48 8 49 9 50 ( 51 ) 52 * 53 + 54 , 55 - 56 . 57 / 58 8 59 9 60 0 61 1 62 2 63 3 64 4 65 5 66 6 67 7 68 8 69 9 70 8 71 9 72 : 73 ; 74 < 75 = 76 > 77 ? 78 8 79 9 80 \80 81 \81 82 \82 83 \83 84 \84 85 \85 86 \86 87 \87 88 \88 89 \89 90 \90 91 \91 92 \92 93 \93 94 \94 95 \95 96 \96 97 \97 98 \98 99 \99 100 @ 101 A 102 B 103 C 104 D 105 E 106 F 107 G 108 8 109 9 110 H 111 I 112 J 113 K 114 L 115 M 116 N 117 O 118 8 119 9 120 P 121 Q 122 R 123 S 124 T 125 U 126 V 127 W 128 8 129 9 130 X 131 Y 132 Z 133 [ 134 \ 135 ] 136 ^ 137 _ 138 8 139 9 140 ` 141 a 142 b 143 c 144 d 145 e 146 f 147 g 148 8 149 9 150 h 151 i 152 j 153 k 154 l 155 m 156 n 157 o 158 8 159 9 160 p 161 q 162 r 163 s 164 t 165 u 166 v 167 w 168 8 169 9 170 x 171 y 172 z 173 { 174 | 175 } 176 ~ 177 178 8 179 9 180 80 181 81 182 82 183 83 184 84 185 85 186 86 187 87 188 88 189 89 190 90 191 91 192 92 193 93 194 94 195 95 196 96 197 97 198 98 199 99 200 € 201 ? 202 ‚ 203 ƒ 204 „ 205 … 206 † 207 ‡ 208 8 209 9 210 ˆ 211 ‰ 212 Š 213 ‹ 214 Œ 215 ? 216 Ž 217 ? 218 8 219 9 220 ? 221 ‘ 222 ’ 223 “ 224 ” 225 • 226 – 227 — 228 8 229 9 230 ˜ 231 ™ 232 š 233 › 234 œ 235 ? 236 ž 237 Ÿ 238 8 239 9 240 _ 241 ¡ 242 ¢ 243 £ 244 ¤ 245 ¥ 246 ¦ 247 § 248 8 249 9 250 ¨ 251 © 252 ª 253 « 254 ¬ 255 _ 256 ® 257 ¯ 258 8 259 9 260 ° 261 ± 262 ² 263 ³ 264 ´ 265 µ 266 ¶ 267 · 268 8 269 9 270 ¸ 271 ¹ 272 º 273 » 274 ¼ 275 ½ 276 ¾ 277 ¿ 278 8 279 9 280 80 281 81 282 82 283 83 284 84 285 85 286 86 287 87 288 88 289 89 290 90 291 91 292 92 293 93 294 94 295 95 296 96 297 97 298 98 299 99 300 À 301 Á 302  303 à 304 Ä 305 Å 306 Æ 307 Ç 308 8 309 9 310 È 311 É 312 Ê 313 Ë 314 Ì 315 Í 316 Î 317 Ï 318 8 319 9 320 Ð 321 Ñ 322 Ò 323 Ó 324 Ô 325 Õ 326 Ö 327 × 328 8 329 9 330 Ø 331 Ù 332 Ú 333 Û 334 Ü 335 Ý 336 Þ 337 ß 338 8 339 9 340 à 341 á 342 â 343 ã 344 ä 345 å 346 æ 347 ç 348 8 349 9 350 è 351 é 352 ê 353 ë 354 ì 355 í 356 î 357 ï 358 8 359 9 360 ð 361 ñ 362 ò 363 ó 364 ô 365 õ 366 ö 367 ÷ 368 8 369 9 370 ø 371 ù 372 ú 373 û 374 ü 375 ý 376 þ 377 ÿ 378 8 379 9 380 80 381 81 382 82 383 83 384 84 385 85 386 86 387 87 388 88 389 89 390 90 391 91 392 92 393 93 394 94 395 95 396 96 397 97 398 98 399 99 400 |
It should be more educative to post code than result of script
Something like: Code:
#!/bin/bash |
All times are GMT -5. The time now is 09:26 AM. |