a = ord("A") # this function is missing in godot 4.0 beta 1

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By play3577

is there any way to convert char to ascii number?

1 Like
:bust_in_silhouette: 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

2 Likes