Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | play3577 |
is there any way to convert char to ascii number?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | play3577 |
is there any way to convert char to ascii number?
Reply From: | BoxyLlama |
If you wanted to convert a single character to ascii, you could do something like this.
3.x:
a = ord("A")
4.x:
a = "A".to_ascii_buffer()[0] # Faster, but assumes ASCII/Latin-1 characters
b = "B".to_utf8_buffer()[0] # Slower, but supports UTF-8
c = "C".unicode_at(0) # Returns as a single int value, instead of PackedByteArray
More detailed documentation about the to_ascii_buffer, to_utf8_buffer, and unicode_at functions can be found here in the Latest String Class Documentation