Hi Colin,
On Wed, 29 Aug 2018, Colin wrote:
> Mitchell,
>
> I tried what you said and got the same results. However, I am still stuck. Here is an example of what I am trying to achieve: I have a file with 256 bytes where the first byte is 0x00, then 0x01, and so on up to 0xFF as the last byte in the file. I would like to be able to open this file in TA and see blobs for bytes 0-31 and 128-255 with normal characters for everything in between. What I see for bytes 128-255 is essentially ISO 8859-1 representation (CP-1252) when buffer.encoding is nil. I suspect this would work as I expect on my Mac.
>
> After playing around with buffer:set_encoding and the list of GNU iconv encodings I was able to change the encoding to CP862 (which doesn't display at all like what I want) and then undo the encoding change (CTRL-Z twice) which caused the file displays as I expect (blobs for 0-31, 128-255). The status bar says the encoding is still CP862.
>
> I don't understand this behavior. I understand that TA isn't designed to be a binary file editor, but it seems so close. I hope I have made my issue clear.
Textadept should always open your file in binary mode. There's no need to play with encodings. I have created a similar file to yours with 256 bytes from 0 to 255. Textadept opens this file in binary mode and shows blobs for 0-31, and ISO 8859-1 for 128-255. When I run:
for i=128,255 do buffer.representation[string.char(i)]=string.format('0x%X',i) end
from the command entry, I get '0xYY' blobs for 128 to 255.
In order to do this on file load, I was able to put this in my *~/.textadept/init.lua*:
events.connect(events.FILE_OPENED, function()
if buffer.encoding == nil then
for i = 128, 255 do
buffer.representation[string.char(i)] = string.format('0x%X', i)
end
end
end)
I hope I'm understanding what you're trying to do. It's still not entirely clear to me, at least when it came to you playing around with encodings.
Cheers,
Mitchell
-- You are subscribed to code.att.foicica.com. To change subscription settings, send an e-mail to code+help.att.foicica.com. To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.Received on Sat 01 Sep 2018 - 10:46:37 EDT
This archive was generated by hypermail 2.2.0 : Sun 02 Sep 2018 - 06:35:27 EDT