sbbs.el

Check-in [17bd3b2661]
Login
Overview
Comment:Fixed non-ASCII encoding issues
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: 17bd3b26618a4f168c5bc44ac6e9b1c501ec869df7336347b09b9ec8d0dac2c6
User & Date: zge on 2020-06-05 20:45:31
Other Links: branch diff | manifest | tags
References
2020-06-05
21:47 New ticket [ed8a04be6b] Error is thrown when rendering some links. artifact: ba47e99903 user: zge
Context
2020-06-05
21:38
Use Shift-JIS font for text if installed check-in: 5ffdf5dd20 user: zge tags: master, trunk
20:45
Fixed non-ASCII encoding issues check-in: 17bd3b2661 user: zge tags: master, trunk
2020-05-31
15:58
Extend code face over newlines check-in: 94c577ae4d user: zge tags: master, trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified sbbs.el from [40f6a50d8a] to [cec4081882].

   335    335            (dolist (o (overlays-at sbbs--last-spoiler))
   336    336              (when (overlay-get o 'sbbs-uncover-p)
   337    337                (delete-overlay o)))
   338    338            (setq sbbs--last-spoiler nil))))
   339    339   
   340    340    ;; URL.EL CALLBACKS
   341    341   
          342  +(defun sbbs--fix-encoding ()
          343  +  "Convert the raw response after point to utf-8."
          344  +  (save-excursion
          345  +    ;; see http://textboard.org/prog/39/263
          346  +    (set-buffer-multibyte nil)
          347  +    (while (search-forward-regexp
          348  +            ;; rx generates a multibyte string, that confuses
          349  +            ;; search-forward-regexp, therefore the regexp literal
          350  +            ;; here
          351  +            "[\x80-\xff]\\(\\(?:\\\\[0-7]\\{3\\}\\)+\\)" 
          352  +            nil t)
          353  +      (let (new)
          354  +        (goto-char (match-beginning 1))
          355  +        (while (< (point) (match-end 1))
          356  +          (push (string-to-number (buffer-substring
          357  +                                   (+ (point) 1)
          358  +                                   (+ (point) 4))
          359  +                                  8)
          360  +                new)
          361  +          (forward-char 4))
          362  +        (replace-match (apply #'string (nreverse new))
          363  +                       nil t nil 1))))
          364  +  (set-buffer-multibyte t)
          365  +  (decode-coding-region (point) (point-max)
          366  +                        'utf-8))
          367  +
   342    368   (defun sbbs--board-loader (status buf)
   343    369     "Callback function for `url-retrieve' when loading board.
   344    370   
   345    371   Load results into buffer BUF. STATUS is used to check for
   346    372   errors."
   347    373     (when (buffer-live-p buf)
   348    374       (when (plist-get status :error)
   349    375         (error "Error while loading: %s"
   350    376                (cdr (plist-get status :error))))
   351         -    (decode-coding-region (point-min) (point-max) 'utf-8)
   352    377       (forward-paragraph)
          378  +    (sbbs--fix-encoding)
   353    379       (let ((list (read (current-buffer))))
   354    380         (kill-buffer)
   355    381         (with-current-buffer buf
   356    382           (let (ent)
   357    383             (dolist (thread list)
   358    384               (push (list (car thread)
   359    385                           (vector (substring (cdr (assq 'date (cdr thread)))
................................................................................
   375    401   load. STATUS is used to check for errors."
   376    402     (when (buffer-live-p buf)
   377    403       (when (plist-get status :error)
   378    404         (error "Error while loading: %s"
   379    405                (cdr (plist-get status :error))))
   380    406       (prog-mode)
   381    407       (forward-paragraph)
   382         -    (decode-coding-region (point) (point-max) 'utf-8)
          408  +    (sbbs--fix-encoding)
   383    409       (save-excursion
   384    410         (save-match-data
   385    411           (while (search-forward "#f" nil t)
   386    412             (unless (cadddr (syntax-ppss))
   387    413               (replace-match "nil")))))
   388    414       (save-excursion
   389    415         (save-match-data