Differences From
Artifact [40f6a50d8a]:
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