Skip to content

Instantly share code, notes, and snippets.

@uchidev
Created February 11, 2016 22:30
Show Gist options
  • Select an option

  • Save uchidev/ce8d9afc8b2b6317839b to your computer and use it in GitHub Desktop.

Select an option

Save uchidev/ce8d9afc8b2b6317839b to your computer and use it in GitHub Desktop.
UTF-8/UTF-16
(apply 'concat '("a" "b"))
;; "ab"
(mapconcat #'(lambda (x) x) '("a" "b") "")
;; "ab"
(mapconcat #'(lambda (x) (char-to-string x)) "ab" "")
;; "ab"
(mapconcat #'(lambda (x) (char-to-string x)) '(?a ?b) "")
;; "ab"
'(?a ?b)
;; (97 98)
(mapconcat #'(lambda (x) (format "%02x" x)) "abc" "_")
;; "61_62_63"
(mapconcat #'(lambda (x) (format "%X" x)) "あいう" "_")
;; "3042_3044_3046"
(mapconcat #'(lambda (x) (format "%X" x)) (encode-coding-string "あいう" 'utf-8) "_")
;; "E3_81_82_E3_81_84_E3_81_86"
(mapconcat #'(lambda (x) (format "%X" x)) (encode-coding-string "あいう" 'utf-16be) "_")
;; "30_42_30_44_30_46"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment