Skip to main content
Fix my typo added while quickly adding the case for the Swedish å in to the script
Source Link
Heikki
  • 3.1k
  • 14
  • 19

As @db48x says, the core problem is in the input method you use. Instead of creating precomposed Unicode characters, you keep producing the decomposed character pairs. This should not happen if your macOS keyboard language is set up to Swedish.

I usually run into this problem when I copy text from a browser or some other text source like a PDF. The text has been converted to that format and the conversion does the sloppy job of coding the Scandinavian characters using decomposed Unicode characters.

As a quick fix, here is a naive brute force emacs-lisp function I use to fix those texts:

(defun my-fix-umlauts (@begin @end) "Replace 「ä」and 「å」 and 「ö」 by 「ä」 and 「å」and 「ö」 in the current line or selection." (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (line-beginning-position) (line-end-position)))) (save-excursion (save-restriction (narrow-to-region @begin @end) (goto-char (point-min)) (while (re-search-forward "ä" nil t) (replace-match "ä" "FIXEDCASE")) (goto-char (point-min)) (while (re-search-forward "ä""ö" nil t) (replace-match "ä""ö" "FIXEDCASE")) (goto-char (point-min)) (while (re-search-forward "å" nil t) (replace-match "å" "FIXEDCASE"))))) 

As @db48x says, the core problem is in the input method you use. Instead of creating precomposed Unicode characters, you keep producing the decomposed character pairs. This should not happen if your macOS keyboard language is set up to Swedish.

I usually run into this problem when I copy text from a browser or some other text source like a PDF. The text has been converted to that format and the conversion does the sloppy job of coding the Scandinavian characters using decomposed Unicode characters.

As a quick fix, here is a naive brute force emacs-lisp function I use to fix those texts:

(defun my-fix-umlauts (@begin @end) "Replace 「ä」and 「å」 and 「ö」 by 「ä」 and 「å」and 「ö」 in the current line or selection." (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (line-beginning-position) (line-end-position)))) (save-excursion (save-restriction (narrow-to-region @begin @end) (goto-char (point-min)) (while (re-search-forward "ä" nil t) (replace-match "ä" "FIXEDCASE")) (goto-char (point-min)) (while (re-search-forward "ä" nil t) (replace-match "ä" "FIXEDCASE")) (goto-char (point-min)) (while (re-search-forward "å" nil t) (replace-match "å" "FIXEDCASE"))))) 

As @db48x says, the core problem is in the input method you use. Instead of creating precomposed Unicode characters, you keep producing the decomposed character pairs. This should not happen if your macOS keyboard language is set up to Swedish.

I usually run into this problem when I copy text from a browser or some other text source like a PDF. The text has been converted to that format and the conversion does the sloppy job of coding the Scandinavian characters using decomposed Unicode characters.

As a quick fix, here is a naive brute force emacs-lisp function I use to fix those texts:

(defun my-fix-umlauts (@begin @end) "Replace 「ä」and 「å」 and 「ö」 by 「ä」 and 「å」and 「ö」 in the current line or selection." (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (line-beginning-position) (line-end-position)))) (save-excursion (save-restriction (narrow-to-region @begin @end) (goto-char (point-min)) (while (re-search-forward "ä" nil t) (replace-match "ä" "FIXEDCASE")) (goto-char (point-min)) (while (re-search-forward "ö" nil t) (replace-match "ö" "FIXEDCASE")) (goto-char (point-min)) (while (re-search-forward "å" nil t) (replace-match "å" "FIXEDCASE"))))) 
Source Link
Heikki
  • 3.1k
  • 14
  • 19

As @db48x says, the core problem is in the input method you use. Instead of creating precomposed Unicode characters, you keep producing the decomposed character pairs. This should not happen if your macOS keyboard language is set up to Swedish.

I usually run into this problem when I copy text from a browser or some other text source like a PDF. The text has been converted to that format and the conversion does the sloppy job of coding the Scandinavian characters using decomposed Unicode characters.

As a quick fix, here is a naive brute force emacs-lisp function I use to fix those texts:

(defun my-fix-umlauts (@begin @end) "Replace 「ä」and 「å」 and 「ö」 by 「ä」 and 「å」and 「ö」 in the current line or selection." (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (line-beginning-position) (line-end-position)))) (save-excursion (save-restriction (narrow-to-region @begin @end) (goto-char (point-min)) (while (re-search-forward "ä" nil t) (replace-match "ä" "FIXEDCASE")) (goto-char (point-min)) (while (re-search-forward "ä" nil t) (replace-match "ä" "FIXEDCASE")) (goto-char (point-min)) (while (re-search-forward "å" nil t) (replace-match "å" "FIXEDCASE")))))