[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Subsets of Unicode and coding systems
From: |
Eli Zaretskii |
Subject: |
Re: Subsets of Unicode and coding systems |
Date: |
Tue, 06 Dec 2011 07:08:49 -0500 |
> Date: Tue, 6 Dec 2011 12:38:57 +0100
> From: Ulrich Mueller <address@hidden>
>
> Sometimes I want to check if a file saved in UTF-8 encoding contains
> only characters from a certain subset of the Unicode character
> repertoire, like the MES-* [1] or WGL4 [2] subsets. (For example, for
> things published on the WWW one might rather avoid exotic characters
> for better compatibility.)
>
> My idea was now to define a coding system e.g. for MES-2 and set the
> buffer-file-coding-system accordingly, so that Emacs would check it
> upon saving the file.
>
> Now I have the following questions:
> 1. Is using coding systems for this purpose a reasonable approach
> at all, or is there a better way to achieve this?
I don't think defining a new coding-system is the best way to go about
this. I would suggest to define a new category instead, see
"(elisp)Categories" (which includes a working example), and then make
a category table (which is just a special type of char-table) where
the relevant characters are marked with the appropriate categories.
Then you can simply scan the buffer with a regexp that uses "\\Cx"
where "x" is the letter you assign to your category. (You will
probably need a separate letter for each of the MES-* and WGL4 sets.)
> 2. Where can I find documentation how to define a coding system?
You don't want to know that ;-)