aboutsummaryrefslogtreecommitdiff
path: root/sx-encoding.el
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2015-01-04 18:11:41 -0500
committerSean Allred <code@seanallred.com>2015-01-04 18:11:41 -0500
commitd3417ee55acc35a14ed71ccd69a593cfed3796bb (patch)
treefd70ff3f8773a4317ec1ea3f753338b374327318 /sx-encoding.el
parent5efc20c03be3c668d780e1909a314bf244bc723d (diff)
parent97130cb7154fc494745d6b2a2a347c765403c5f3 (diff)
Merge pull request #198 from vermiculus/organize
Organize
Diffstat (limited to 'sx-encoding.el')
-rw-r--r--sx-encoding.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/sx-encoding.el b/sx-encoding.el
index 795f175..d8ad2ba 100644
--- a/sx-encoding.el
+++ b/sx-encoding.el
@@ -1,4 +1,4 @@
-;;; sx-encoding.el --- encoding -*- lexical-binding: t; -*-
+;;; sx-encoding.el --- encoding -*- lexical-binding: t; -*-
;; Copyright (C) 2014 Sean Allred
@@ -19,10 +19,18 @@
;;; Commentary:
+;; This file handles decoding the responses we get from the API. They
+;; are received either as plain-text or as a `gzip' compressed archive.
+;; For this, `sx-encoding-gzipped-p' is used to determine if content
+;; has been compressed under `gzip'.
+
;;; Code:
(require 'cl-lib)
+
+;;;; HTML Encoding
+
(defcustom sx-encoding-html-entities-plist
'(Aacute "Á" aacute "á" Acirc "Â" acirc "â" acute "´" AElig "Æ" aelig "æ"
Agrave "À" agrave "à" alefsym "ℵ" Alpha "Α" alpha "α" amp "&" and "∧"
@@ -86,6 +94,9 @@ Return the decoded string."
(substring ss 1))))))))
(replace-regexp-in-string "&[^; ]*;" get-function string)))
+
+;;;; Convenience Functions
+
(defun sx-encoding-normalize-line-endings (string)
"Normalize the line endings for STRING.
The API returns strings that use Windows-style line endings.
@@ -131,6 +142,9 @@ some cases."
(cl-map #'vector #'sx-encoding-clean-content-deep data))
(t data))))
+
+;;;; GZIP
+
(defun sx-encoding-gzipped-p (data)
"Check for magic bytes in DATA.
Check if the first two bytes of a string in DATA match the magic