self
contains only digits and alpha <= 'f', return the corresponding integer.assert "ff".to_hex == 255
# If `self` contains only digits and alpha <= 'f', return the corresponding integer.
#
# ~~~
# assert "ff".to_hex == 255
# ~~~
fun to_hex(pos, ln: nullable Int): Int do
var res = 0
if pos == null then pos = 0
if ln == null then ln = length - pos
var max = pos + ln
for i in [pos .. max[ do
res <<= 4
res += self[i].from_hex
end
return res
end
lib/core/text/abstract_text.nit:275,2--290,4
# If `self` contains only digits and alpha <= 'f', return the corresponding integer.
#
# assert "ff".to_hex == 255
redef fun to_hex(pos, ln) do
var res = 0
if pos == null then pos = 0
if ln == null then ln = length - pos
pos = char_to_byte_index(pos)
var its = _items
var max = pos + ln
for i in [pos .. max[ do
res <<= 4
res += its[i].code_point.from_hex
end
return res
end
lib/core/text/flat.nit:386,2--401,4