Re: [code] Re: [textadept] Feature request: control characters / BOM

From: Mitchell <>
Date: Sat, 9 Aug 2014 09:37:34 -0400 (EDT)

Hi Joshua,

On Fri, 8 Aug 2014, Joshua Krämer wrote:

> On 2014-08-07, 12:24, Mitchell wrote:
>> On Wed, 6 Aug 2014, Joshua Krämer wrote:
>>> Textadept prints control characters (like ESC or LF) in an
>>> inverted-colour box; but only some control characters seem to be
>>> respected. I miss for example the BOM (U+FEFF), ZWNJ (U+200C) and
>>> ZWJ (U+200D).
>> You should be able to do this via `buffer.representation`[1]. More
>> info can be found here[2].
> Thanks, but could you please give an example of the format to be
> used for the buffer.representation value? This for example didn't
> work (trying to implement the example at [2]):
> control_string = {}
> control_string["\xe2\x84\xa6"] = "U+2126 \xe2\x84\xa6"
> buffer.representation = control_string
> This also didn't work:
> buffer.representation = {"\xe2\x84\xa6", "U+2126 \xe2\x84\xa6"}

`buffer.representation` is "indexable" and acts like an already existing

   buffer.representation['\xe2\x84\xa6'] = 'U+2126 \xe2\x84\xa6'

>>> Regarding BOM, it would be nice to have a menu item to insert it at
>>> the beginning of the file. I would prefer the BOM to be shown as a
>>> regular character at the beginning of the file, instead of
>>> implementing BOM support as part of the file encoding, as done by
>>> some editors.
>> I'm no encoding expert so I'd prefer not to add that menu item or
>> others that users might expect (UTF-16LE, UTF-16BE, UTF-32..., etc.)
>> I think it's sufficient for you to add a menu item (e.g. to the Tools
>> menu) that sets `io.encoding_bom`.
> You mean buffer.encoding_bom? This is sufficient, yes.

Yes, `buffer.encoding_bom`, thanks.

>> I've never seen an editor display a BOM in the editor view. Doing so
>> would certainly confuse me. There's also the question of whether or
>> not to make the BOM char read-only. I think it's easier to avoid all
>> of this and simply treat the BOM behind the scenes.
> The reason I asked about the BOM is that I struggled with a text file
> that included a BOM and didn't work with a program that obviously has
> no BOM support. Textadept didn't inform me about the BOM, so I didn't
> know it was there and wondered what the problem could be. Thinking the
> file must be corrupt somehow, I inspected it with xxd, and only then I
> realized there was a BOM present (and this turned out to be the
> problem). This is why I suggested to show the BOM in the editor view.
> This way the user could easily see it and could easily remove it, too.
> But I understand this may not be desirable for everybody. At least,
> somehow the user should be informed about the presence of the BOM
> (in the status bar, next to the encoding).

Yes, a notice in the statusbar about a BOM is a fine idea. I'll commit


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Sat 09 Aug 2014 - 09:37:34 EDT

This archive was generated by hypermail 2.2.0 : Sun 10 Aug 2014 - 06:34:35 EDT