The standard Emacs way to do this is C-x 8 RET followed by either the Unicode code point (a natural number) or the Unicode name of the character. Completion is available for the name.
If you use library Icicles then you can complete the name using parts of it, with multiple patterns matching different parts, if you want. And you can see the characters ...
If you are familiar with TeX, you will find the TeX input method helpful. Just do
M-x set-input-method TeX
then type something like \alpha — it will be replaced with the corresponding Unicode character. You can switch the input method off by typing C-\.
You can find all the supported TeX commands with
So the requirement is: When I'm using the arabic input method, and I type a digit, I want Emacs to insert the Hindi character for that digit.
To do this, we can adapt your linked approach to extend an input-method like so:
'(let ((quail-current-package (assoc "arabic" quail-package-alist)))
For some reason, Emacs isn't recognizing the file as UTF-8.
You can force Emacs to reopen the file as UTF-8 by running the command C-x RET r (revert-buffer-with-coding-system) and entering utf-8.
The reason why Emacs didn't recognize this file as UTF-8 (but recognizes other) is likely that it contains some invalid UTF-8 sequence. This sequence will still ...
C-q 377 RET inserts the character with octal code 377 (aka LATIN SMALL LETTER Y WITH DIAERESIS). If you want to insert a byte instead of a character, you can do it with:
M-: (insert (unibyte-string #o377)) RET
As @legoscia mentioned, Emacs will probably ask you to use another coding system after inserting such a character, but you can choose utf-8 at that ...
Depending on your preference, you can use the following line in your .emacs to set your default coding system to utf-8. That resolved the problem for me, and I haven't noticed any other negative side effects yet.
In addition to C-x 8 RET, mentioned here that lets you insert any character by name, C-x 8 also has many shortcuts for inserting common characters. In this case, C-x 8 o inserts "°". See them all with C-x 8 C-h
The C-x 8 keymap is also a good place to define your own shortcuts to insert the characters you use most often. The Greek letters aren't bound to ...
There's a very underappreciated feature most libraries that handle fonts provide for us, automatic fallback to different fonts if the font one has specified does not have all glyphs necessary to display the requested text correctly.
urxvt however does intentionally not come with automatic font fallback, at least not if you're not using fonts with the xft: ...
1) How shall I avoid creating a text file with mixed encodings when copying its different parts from different sources into an editor such as emacs?
Irrespective of the source, you can always set the encoding of a buffer by setting the variable buffer-file-coding-system. An easy way to do this is via the keybinding C-x RET f which prompts you for a file ...
When I copy the text from the source to the emacs buffer ...
What you copy depends upon the application you are copying from. Some applications release UTF-8 encoded strings while others use different formats. Emacs uses the variable selection-coding-system to determine whether to decide the encoding from the data or presume a particular encoding. See the ...
There's no general way to find out what input methods give access to a given set of characters. An input method is written in Emacs Lisp, and it can use any Emacs Lisp primitives to build characters. From a quick look under lisp/leim/quail, I see that the latin-4-postfix, latin-4-alt-postfix, and TeX input methods include vowels with macrons.
The whole ...
There is a new feature in Emacs from version 24.4 for using Unicode strings to access filenames in Windows. This allows using filenames containing characters that are not in the locale's 8-bit character set, which was previously impossible.
Emacs on Windows 2000 and later can now access files and ...
This happened to me for a while also before I had an idea of what was going on - here's an example of how something like this can happen - (if it matters, I'm on Windows, in case it's something specific to this build) -
Let's say you have a file that's encoded in UTF-8, and you paste some text from a website that's encoded with the Latin-1 or Windows-1252 ...
This is the MacRoman encoding, a legacy encoding from the pre-OSX days of Mac OS. It is available in Emacs as mac-roman.
C-x RET r mac-roman RET yes RET
You may need to select mac-roman-mac, mac-roman-dos or mac-roman-unix explicitly if Emacs doesn't automatically detect the representation of line endings. The mac-roman part is for the encoding of non-...
IIUC the problem is that the string you insert is undecoded, i.e. it's a string of bytes you received over the network. So you need to find out what character encoding is used/assumed by the sender (typically utf-8 these days), then call decode-coding-string with this encoding, and then insert the string it returns (which will be a string of characters).
After some trial and error, I managed to convert ÿ to the byte 377 using M-x recode-region, specifying that it was really in raw-text but was interpreted as latin-1.
When saving the file, Emacs didn't want to save it as UTF-8, offering to save it as raw-text instead, which seems to have had the desired effect.
global-set-key is just a thin wrapper around define-key, ignoring some error checking it is
(defun global-set-key (key def)
(define-key (current-global-map) key def))
The documentation for define-key says that the "def" can be a number of things, including
a string (treated as a keyboard macro),
So then there is the question about what something like ...
From chapter "Choosing Coding Systems for Output" of emacs manual:
Once Emacs has chosen a coding system for a buffer, it stores that
coding system in ‘buffer-file-coding-system’. That makes it the default
for operations that write from this buffer into a file, such as
‘save-buffer’ and ‘write-region’. You can specify a different coding
I wrote a function and added to find-file-not-found-functions
(defun srs-set-new-sql-file-coding-system ()
(if (string-match "\\.d?sql\\'" buffer-file-name)
(setq buffer-file-coding-system 'utf-8-with-signature-dos)
(add-hook 'find-file-not-found-functions 'srs-set-new-sql-file-coding-system)
Why not use the same mechanism that describe-char uses to identify whether a character is encodable using utf-8 i.e. use encode-coding-char. From the documentation
Encode CHAR by CODING-SYSTEM and return the resulting string. If
CODING-SYSTEM can't safely encode CHAR, return nil. The 3rd optional
argument CHARSET, if non-nil, is a charset preferred ...
I have dealt with this issue a lot. The encoding will be depending on information in the file. If there is no information in the file explicitly to determine what it is, you could get such things as above.
If your work doesn't involve a lot of ancient systems which require different coding, you could consider to force default UTF-8 coding everywhere.
If you can edit the file, you can specify the pseudo-variable coding as a file-local variable.
e.g.: -*- coding: japanese-iso-8bit; -*-
If you can't (or don't want to) edit the file, but this is only needed for yourself, then the "Using Directory Local Variable classes for individual files" trick described on that same page would be an option; but using ...
What is going on is that string in Emacs have historically been used in this context for 2 different purposes:
sequence of characters.
sequence of events.
In your case, you're writing what you think as a sequence of characters, but it's used in a context where Emacs expects a sequence of events.
Since Emacs-19 added support for GUIs, events have become a ...
Sounds like you are asking for something like this:
(defun region-bytes ()
(let ((strg (if (use-region-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(message "Region has %d bytes" (string-bytes strg))))
You might also be interested in showing the region size in the mode ...
Emacs decodes a text file with an appropriate coding system when you open it with find-file.
If you have to tell emacs for some reason what coding system it should use for decoding the file you should do so before you open the file.
You can set the coding system for the next command with Options -> Multilingual Environment -> Set Coding Systems -> For Next ...
Do I need to make Magit aware of my file system encoding. If so, how?
By configuring Git accordingly using core.eol and related variables described in git-config(1). By asking a search engine about "git end of file" you can find more information.
One complication when it comes to Magit is that it may display diffs for multiple files in the same Emacs ...
Thanks to wvxvw's comment, I can answer my own (main) question: in order to convert a TeX-encoded file, say foo.tex, into an UTF-8 encoded one, it is enough to run (no need to open the file in emacs):
emacs -batch foo.tex -f mark-whole-buffer -f iso-tex2iso -f save-buffer -kill