Новости | FAQ | Авторы | Документация | В действии | Библиотека |
Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
G_Z 18.10.2005 00:19 / 18.10.2005 00:20
Методы для преобразования IP в строку (8символов).#================================================================================================== @ipToStr[ip][parts;digit] $parts[^ip.split[.][v]] ^parts.menu{ $digit(^parts.piece.int(0)) $result[$result^digit.format[%.02x]] } #================================================================================================== #================================================================================================== @strToIp[str][position] $result[^for[position](0;^math:ceiling(^str.length[] / 2) - 1){^hexToInt[^str.mid($position * 2;2)]}[.]] #================================================================================================== #================================================================================================== @hexToInt[hex][letters_to_digits;hex_length;position;digit;pow] $letters_to_digits[^table::create{from to a 10 b 11 c 12 d 13 e 14 f 15 A 10 B 11 C 12 D 13 E 14 F 15}] $hex_length(^hex.length[]) ^for[position](1;$hex_length){ $digit[^hex.mid($position - 1;1)] $digit[^digit.replace[$letters_to_digits]] $digit(^digit.int(0)) $pow($hex_length - $position) $result($result + $digit * ^math:pow(16;$pow)) } #==================================================================================================