Article 5G03R Python3: chr() and certain non-ASCII character codes

Python3: chr() and certain non-ASCII character codes

by
rnturn
from LinuxQuestions.org on (#5G03R)
(Subtitle: chr(157), chr(158), and chr(159): The characters whose display is forbidden. [play scary music])

My goal was to find the proper integer to pass to chr() to obtain a white block to use for a progress bar. (Code 219(10) in the old Code page 437 character set.)

I'm trying to figure out why the following script doesn't fully execute:
Code:#!/usr/bin/python3
#chardisp
for N in range( 0, 1114111 ):
print( "%d : %s" % ( N, chr(N) ) )The upper limit (1114111) is what the Python3 documentation pages state as the maximum allowable to pass to chr().

It never displays anything once it hit N=157. I was able to display much of the rest of the characters by tweaking the loop range. It turns out that everything in the range 157-159 is non-displayable and makes the for loop terminate early with an exit status of "0".

Code:$ ./chardisp
0 :
1 :
2 :
3 :
4 :
5 :
6 :
7 :
8 :
9 :
10 :

11 :

12 :

13 :
14 :
15 :
16 :
17 :
18 :
19 :
20 :
21 :
22 :
23 :
24 :
25 :
26 :
27 :
8 :
29 :
30 :
31 :
32 :
33 : !
34 : "
35 : #
36 : $
...

120 : x
121 : y
122 : z
123 : {
124 : |
125 : }
126 : ~
127 :
128 :
129 :
130 :
131 :
...

151 :
152 :
154 :
155 :

157 : 12
$Oddly, there's nothing being displayed for N=[127,156]. (N=156 appears to be some sort of delete line code.)

Any reason why this little script's output terminates early when it hits 157, 158, or 159?

TIA...

(I was able to find the character I was looking for. It's chr(9619).)latest?d=yIl2AUoC8zA latest?i=GSa1A5htn-Y:69XvZL50PNs:F7zBnMy latest?i=GSa1A5htn-Y:69XvZL50PNs:V_sGLiP latest?d=qj6IDK7rITs latest?i=GSa1A5htn-Y:69XvZL50PNs:gIN9vFwGSa1A5htn-Y
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments