equal
deleted
inserted
replaced
943 (lambda (x) |
943 (lambda (x) |
944 (concat (unibyte-string (string-to-number (substring x 0 2) 16)) (substring x 2))) |
944 (concat (unibyte-string (string-to-number (substring x 0 2) 16)) (substring x 2))) |
945 (cdr s)) |
945 (cdr s)) |
946 )) 'utf-8)) |
946 )) 'utf-8)) |
947 |
947 |
948 (defun my-percent-decode-region (arg beg end) |
948 (defun my-percent-decode-region (beg end &optional arg) |
949 "Convert percent encoded string to native." |
949 "Convert percent encoded string to native." |
950 (interactive "P\nr") |
950 (interactive "r\nP") |
951 (let ( (result (my-percent-decode (buffer-substring-no-properties beg end))) ) |
951 (let ( (result (my-percent-decode (buffer-substring-no-properties beg end))) ) |
952 (if (not arg) |
952 (if (not arg) |
953 (message result) |
953 result |
|
954 (delete-region beg end) |
|
955 (insert result)) |
|
956 ) ) |
|
957 |
|
958 (defun my-percent-encode (str) |
|
959 (apply 'concat |
|
960 (mapcar |
|
961 (lambda (ch) (if (or (and (<= ?a ch) (>= ?z ch)) |
|
962 (and (<= ?A ch) (>= ?Z ch)) |
|
963 (memq ch '(?- ?_ ?. ?~))) |
|
964 (char-to-string ch) |
|
965 (format "%%%02X" ch))) |
|
966 (encode-coding-string str 'utf-8) ))) |
|
967 |
|
968 (defun my-percent-encode-region (beg end &optional arg) |
|
969 "Encode string to percent encoding." |
|
970 (interactive "r\nP") |
|
971 (let ( (result (my-percent-encode (buffer-substring-no-properties beg end))) ) |
|
972 (if (not arg) |
|
973 result |
954 (delete-region beg end) |
974 (delete-region beg end) |
955 (insert result)) |
975 (insert result)) |
956 ) ) |
976 ) ) |
957 |
977 |
958 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
978 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |