17 |
|
|
18 |
|
size_t index(string.GetSize() % 2), offset(index); |
19 |
|
|
20 |
< |
_rmforeach (ext::Vector<byte_t>, byte, bytes) _rfor (byte_t, half, 0, 2) *byte |= hex(string[index++]) << half * 4; |
20 |
> |
_rforeach (ext::Vector<byte_t>, byte, bytes) _rfor (byte_t, half, 0, 2) *byte |= hex(string[index++]) << half * 4; |
21 |
|
|
22 |
|
if (offset != 0) |
23 |
|
{ |
24 |
|
bytes.InsertLast(0); |
25 |
|
|
26 |
|
bytes.Last() |= hex(string[0]); |
27 |
< |
bytes.Last() |= signed_ && bytes.Last() < 8 ? 0xF0 : 0; |
27 |
> |
bytes.Last() |= signed_ && bytes.Last() > 7 ? 0xF0 : 0; |
28 |
|
} |
29 |
|
} |
30 |
|
|
32 |
|
{ |
33 |
|
ext::String string; |
34 |
|
|
35 |
< |
_rforeach (ext::Vector<byte_t>, byte, bytes) _rfor (byte_t, half, 0, 2) |
35 |
> |
_rforeach (const ext::Vector<byte_t>, byte, bytes) _rfor (byte_t, half, 0, 2) |
36 |
|
{ |
37 |
|
byte_t hex(0xF & *byte >> half * 4); |
38 |
|
|
43 |
|
|
44 |
|
return string; |
45 |
|
} |
46 |
+ |
|
47 |
+ |
inline byte_t Hexadecimal::hex(const ext::CodePoint& atom) |
48 |
+ |
{ |
49 |
+ |
if (atom >= '0' && atom <= '9') return atom - '0'; else if (atom >= 'a' && atom <= 'f') return atom - 'a' + 0xA; else if (atom >= 'A' && atom <= 'F') return atom - 'A' + 0xA; else return 0; |
50 |
+ |
} |