Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
02-04-2005, 12:44 PM
|
#1
|
|
Member
Registered: Jun 2004
Distribution: Slack
Posts: 214
Rep:
|
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
|
|
|
|
02-04-2005, 12:50 PM
|
#2
|
|
Senior Member
Registered: Mar 2004
Distribution: Slackware
Posts: 4,282
Rep:
|
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"
Last edited by keefaz; 02-04-2005 at 12:51 PM.
|
|
|
|
02-04-2005, 12:57 PM
|
#3
|
|
Member
Registered: Jun 2004
Distribution: Slack
Posts: 214
Original Poster
Rep:
|
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.
|
|
|
|
02-04-2005, 01:04 PM
|
#4
|
|
Senior Member
Registered: Mar 2004
Distribution: Slackware
Posts: 4,282
Rep:
|
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.
|
|
|
|
02-04-2005, 01:10 PM
|
#5
|
|
Member
Registered: Jun 2004
Distribution: Slack
Posts: 214
Original Poster
Rep:
|
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.
|
|
|
|
02-04-2005, 01:22 PM
|
#6
|
|
Member
Registered: Jun 2004
Distribution: Slack
Posts: 214
Original Poster
Rep:
|
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
Last edited by nutthick; 02-04-2005 at 01:23 PM.
|
|
|
|
02-04-2005, 02:15 PM
|
#7
|
|
Senior Member
Registered: Mar 2004
Distribution: Slackware
Posts: 4,282
Rep:
|
It should be more educative to post code than result of script
Something like:
Code:
#!/bin/bash
i=0
while [ $i -lt 400 ]; do
printf "%i : %b\n" "$i" "\0$i"
let "i++"
done
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:14 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|