What does it mean? \ xfe in ruby?

I came across the following code and could not understand what was going on.

def self.eof_packet?(data)
  data[0] == ?\xfe && data.length == 5
end
+3
source share
3 answers

?starts a literal letter .

\xlaunches hexadecimal escape .

+8
source

The hexadecimal number of FE, which is 254

+2
source

This is the letter of the hexadecimal character. You can also use 0xfethat also works for large numbers (e.g. 0x100) that do not fit in bytes.

+1
source

Source: https://habr.com/ru/post/1749695/


All Articles