Display the [SOH] control character as a space or in Notepad ++

I am debugging / controlling a log file containing the wide control character [SOH]
This makes the logs barely readable (well, for me, in NP ++, but it should be so, since this character is used in the protocol that I control)

How to show this character more friendly in NP ++?

EDIT : Replacement is not an option, as I just want to file the file, not edit it.

+6
source share
2 answers

Introduction

Notepad ++ uses Scintilla for the editor component. Scintilla has a function SCI_SETCONTROLCHARSYMBOL(int symbol) where you can set the character that will be used for control characters. From the Scintilla docs, they describe the functionality:

SCI_SETCONTROLCHARSYMBOL (int character)

SCI_GETCONTROLCHARSYMBOL

By default, Scintilla displays control characters (characters with codes less than 32) in a rounded rectangle in the form of ASCII mnemonics: "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", " BEL "," BS "," HT "," LF "," VT "," FF "," CR "," SO "," SI "," DLE "," DC1 "," DC2 "," DC3 " , "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US", These Mnemonics occur from the first days of signal transmission, although some are still used (for example, LF = line feed, BS = inverse interval, CR = carriage return).

You can replace these mnemonics with the assigned character with an ASCII code in the range of 32 to 255. If you set the character value to less than 32, all control characters will be displayed as mnemonics. The character you specify is displayed in the font of the style set for the character. You can read the current character using the SCI_GETCONTROLCHARSYMBOL message. The default character value is 0.

There is probably a β€œright” way to do this, but I'm going to give you a very hacky way to do it.

Equipment

Edit the %APPDATA%\Notepad++\shortcuts.xml file using anything EXCEPT Notepad ++.

Add the following to the <Macros> section of the file to manually add the macro:

 <Macro name="RemoveControl" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="0" message="2388" wParam="32" lParam="0" sParam="" /> </Macro> 

Note that you can set a shortcut using the Ctrl , Alt , Shift and Key attributes. wParam set the character to be used instead of the prescribed codes. In this case, code 32 is a space in the ASCII standard. Message 2388 is a constant for the value SCI_SETCONTROLCHARSYMBOL .

Save file

using

Now you can change the behavior of Notepad ++ at runtime. To use this, do the following

Open Notepad ++ Just open the editor. If you open the file directly (i.e., edit using the Notepad ++ context menu), you will get strange behavior.

Activate the macro from the menu (or your shortcut). If there is a way to automate the macro launch at startup, it would be nice to add it here

Open your file. Nothing new here

Notes

  1. Positions with a control character will still be inverted (by default, white text on a black background).
  2. If you activate a macro while the document is open, it will not take effect immediately. You will have to do something to make the window redraw.
  3. Viewing the Scintilla.h file may open other options that could be used in a similar way.
+18
source

If you want to avoid this character in the future, select the session registration function as such in Putty, only Log "printable output". This will print out all unnecessary Scintilla characters.

Regarding Putty (link to caching below):

4.2 Logging panel

The logging configuration panel allows you to save the log files of your PuTTY sessions for debugging, analysis, or future use.

The main parameter is a set of radio buttons that indicates whether PuTTY will register anything at all. Parameters

+ "Recording is completely disabled." This is the default option; in this mode, PuTTY will not create a log file at all.

+ "Print Only Print Only". In this mode, a log file will be created and written, but only printed text will be saved to it. Various terminal control codes that are typically sent in an interactive session along with printed text will be omitted. This can be a useful way if you want to read the log file in a text editor and hope you can understand it.

+ "Record entire session output." In this mode, everything sent by the server to the terminal session is logged. Therefore, if you are viewing the log file in a text editor, you may well find it with really strange control characters. This is a particularly useful mode if you have problems processing the PuTTY terminal: you can record everything that was on the terminal so that someone else can repeat the session later in slow motion and see what happened.

+ "Register SSH packet data." In this mode (which is used only by SSH connections), SSH message packets sent over an encrypted connection are written to the log file. This may be required to debug the problem at the network level or, most likely, to send PuTTY authors as part of the bug report. WARNING: if you log in using a password, the password will be displayed in the log file, so be sure to edit it before sending the log file to anyone else!

LINK: http://webcache.googleusercontent.com/search?q=cache:L0M6HnWRvowJ:the.earth.li/~sgtatham/putty/0.53b/htmldoc/Chapter4.html+&cd=1&hl=en&ct=clnk&gl=us

0
source

Source: https://habr.com/ru/post/905627/


All Articles