This package provides functions to convert text to the German spelling alphabet defined by DIN 5009 (e.g., “A” becomes “Anton”) and back again within Emacs.
- Convert entire strings to DIN 5009 representation (
din5009-string). - Convert DIN 5009 phonetic strings back to standard German spelling (
de5009-string). - Interactive command
din5009-regionto convert the selected region to the DIN 5009 spelling alphabet. - Interactive command
de5009-regionto convert text formatted according to the DIN 5009 spelling alphabet back to regular text in the selected region. - Handles standard letters, numbers, umlauts, Eszett, common punctuation, and the digraph “ch” and trigraph “sch”.
- Customizable separator string (default: “-“) via
din5009-separator. - Includes a test runner command
din5009-run-tests.
- Clone this repository or download
5009-region.el. - Add the directory containing
5009-region.elto your Emacsload-path. - Add
(require '5009-region)to your Emacs configuration file (e.g.,init.el).
Load the package using (require '5009-region).
You can customize the separator used between words:
(setq din5009-separator " ") ; Use space as separator;; Convert a string
(din5009-string "Hallo Welt!")
;; => "Heinrich-Anton-Ludwig-Ludwig-Otto Wilhelm-Emil-Ludwig-Theodor-Ausrufezeichen"
(din5009-string "Ökonomie für ch/sch")
;; => "Ökonom-Kaufmann-Otto-Nordpol-Otto-Martha-Ida-Emil Friedrich-Übermut-Richard Charlotte-Schrägstrich-Schule"
(din5009-string "Text mit 123")
;; => "Theodor-Emil-Xanthippe-Theodor Martha-Ida-Theodor Eins-Zwei-Drei"
;; Convert back from DIN 5009
(de5009-string "Heinrich-Anton-Ludwig-Ludwig-Otto Welt Ausrufezeichen")
;; => "hallo Welt !"
(de5009-string "Ökonom-Kaufmann-Otto-Nordpol-Otto-Martha-Ida-Emil für Charlotte Schrägstrich Schule")
;; => "ökonomie für ch / sch"
(de5009-string "Theodor-Emil-Xanthippe-Theodor mit Eins-Zwei-Drei")
;; => "text mit 123"
;; Using region commands
;; Select text in a buffer and run:
M-x din5009-region
M-x de5009-regionTo run the included tests:
M-x din5009-run-tests
If you want to quickly call the conversion functions using Embark, you can add the following to your Emacs configuration (if you use general; otherwise, you can use the keymap directly):
(general-define-key
:keymaps 'embark-encode-map
"/" 'din5009-region
"?" 'de5009-region)This will allow you to encode and decode using (by default) the shortcuts > / for encoding and > ? for decoding. This is convenient for me, since I trigger embark with C->, but you might choose different keys. It is also similar to the existing bindings for morse-region (> .) and unmorse-region (> -).
This package is distributed under the terms of the GNU General Public License version 3 or later (GPL-3.0-or-later).
Contributions are welcome! Please ensure any pull requests include tests.