chr() is a function in Python or PHP which returns the character (string of length one) that corresponds to an ASCII code point.
Questions tagged [chr]
166 questions
2
votes
0 answers
Issues with cython-hidapi, send_feature_report or chr()
I have this snippet of code which works fine on Windows and Mac OS X using Python 2.7.6. I am using the cython-hidapi intereface to read data from a Voltcraft VC870 power meter. To get the data, if first need to send a feature report to the device…

oche
- 939
- 10
- 19
2
votes
0 answers
Compiling prolog codes with CHR embedded
I have read the user guide for CHRG and I'm having trouble getting my prolog files to work when chrg is embedded. I keep having syntax errors despite following the manual.I am using SWI prolog 6.6.6 and I have also tried SICSTUS Prolog 4.1.2. I have…

Ade
- 21
- 1
2
votes
1 answer
Cython: Fastest way to convert char value to string
I need to convert multiple char values to strings of corresponding ASCII characters as fast as possible. Here is a toy example. I want H() function, called from python environment, to return str 'aaa'.
from libcpp.string cimport string
cdef string…

Apogentus
- 6,371
- 6
- 32
- 33
2
votes
3 answers
vba search replace character
I'm trying to prepare a spreadsheet for a report in excel vba. Unforturnately there are some wierd characters here that need to be replaced. Easy enough, except for this chracter:
¦
I can't seem to be able to paste that character into the editor…

mango
- 5,577
- 4
- 29
- 41
2
votes
2 answers
Reachability constraint in SWI/CLP(FD)
I'm trying to determine that shape of a directed graph by solving constraints on presence of nodes and arcs, e.g., binary variable V1V2 is 1 if there is an arc from node V1 to V2. I would like to express the reachability constraint (or,…

Alexander Serebrenik
- 3,567
- 2
- 16
- 32
2
votes
1 answer
shifting letters using ord and chr
I am trying to do a function that shifts each letter in each word to the right by value
and these words will be from a list that I will open it using "open"function
I wrote the code, and I am facing some difficulties here
here is my code
def…
user2924427
2
votes
1 answer
Difference function Char / Chr in Delphi 2007 and XE3
I am using function Char and Chr with parameter 130 and has behave different in Delphi 2007 e XE3.
Delphi 2007: Char( 130 ) or Chr( 130 ) - Result: Comma
Delphi XE3: Char( 130 ) or Chr( 130 ) - Result: #$0082
I problem resolve using AnsiChar( 130…

Johni Douglas Marangon
- 517
- 5
- 15
2
votes
4 answers
Python Efficiency - Better version than multiple if elif statements - use a for loop - chr ord conversions?
I'm taking an intro to an online Python course and here's the problem description.
Write a program which does the reverse of the example above: it should take a character as input and output the corresponding number (between 1 and 26). Your program…

StacyM
- 1,036
- 5
- 23
- 41
2
votes
2 answers
apply prepends space for logical
Having a strange issue here with apply and R 3.0.1.
I have a huge dataframe with text, numbers and logical values.
The logical values are converted to chr when I use apply, but because
R allows something like TRUE == "TRUE" that isn't a…

Marc
- 238
- 1
- 9
2
votes
1 answer
Counter-intuitive preg_match behavior - what is the cleanest way to match a range of characters?
I am looking for ways to match a range of characters and assumed the following regEx would only match characters in the range of hex codes between 20 and 7E. However, it also matches chr(10) (line feed), in fact, the following prints "passed":
echo…

Dmitri Zaitsev
- 13,548
- 11
- 76
- 110
2
votes
5 answers
Stuck on next letter generator -- Python 3
Currently, I am taking some computer science lessons online. I have been issued the task of writing a program that, upon a valid input, will print the next letter in the alphabet. Here is my code:
char = input()
ordchar = ord(char)
nextletter =…

user2080719
- 73
- 1
- 6
2
votes
3 answers
How this works: chr(($number >>6 )+192).chr(($number & 63)+128);
Can you please explain how this line of code is equivalent to the next code:
> 6 ) + 192 ).chr( ( $number & 63 ) + 128 );
?>
Its equivalent to :
if ( $number >=128 && $number <=2047 ){
$byte1 = 192 +…
user1646111
1
vote
3 answers
PHP- preg_replace on hex char
i have a string, like this:
'Via Universit\E0 4 '
Whit HEX char... i need string become:
'Via Università 4 '
So, i use:
$text= preg_replace('/(\\\\)([a-f0-9]{2})/imu', chr(hexdec("$2")), $text);
But dont…

Andrea
- 265
- 1
- 3
- 13
1
vote
2 answers
Want to see only the chr variables (out of a list of chr and num variables) using str() function
I am using the following to get a sense of which variables are char, num, etc, and it works fine but now I'd like to see only those variables that R classifies as chr. Is there a path to doing so?
str(mtvtn, list.len = ncol(mtvtn))
I tried the…

uThandi
- 11
- 1
1
vote
1 answer
Convert From ASCII W/O chr() Python
I am writing a program to get keyboard inputs. Here is the code:
key = 0
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
for key in keys:
…

Hudson Rocke
- 85
- 5