Simple Sand Samples |
Gauche > 文字列を数値に変換する(文字コードを得る)
str2hex.scm
(use binary.pack) (use slib) (require 'printf) (define src "HELLO") (define dst (unpack "C*" :from-string src)) (map (lambda (x) (printf "%02x\n" x)) dst)
$ gosh str2hex.scm
48
45
4c
4c
4f
$
48
45
4c
4c
4f
$
* 確認環境 Debian Linux(Wheezy)