ANSI escape code, ansiescapecode
Recently, I am working on the SSH Terminal Project on iOS. It is mainly to remotely connect to Unix systems on mobile phones and perform some simple commands, similar to SecureCRT; today I want to summarize the new thing encountered in this project-ANSI escape code.
Excerpt https://en.wikipedia.org/wiki/ansi_escape_codebrief: in computing,ANSI escape codes(OrEscape sequences) Are a method using in-band signaling to control theformatting, color, and other output options on video text terminals. to encode this formatting information, certain sequences of bytes are embedded into the text, which the terminal looks for and interprets as commands, not ascharacter codes. to put it simply, we generally use terminal terminals, such as command terminals on Linux, Mac, and Unix, the ANSI control code is used to control the format and some control operations of the displayed text.
The data transmitted by the terminal contains the ANSI control code, which must be decoded to display the color and font of the text. So I searched for it on github and found it. Here I have to praise the greatness of the open source spirit. Thank you for the coders who contributed to the open source. One thing to note here is that some open-source projects may have been in use for a long time, and the author has not updated them. They may be inconsistent with your requirements. We need to modify some things when using them simply and rudely, I think this is a good opportunity to learn. You can read the source code and make some modifications that meet your needs.
Summary: first, this article mainly introduces the text format of the processing terminal. What you need to know is the ANSI escape code, an open-source project for decoding on github. Second, I think, necessary end for blog writing, hey ~ This kind of project was rarely done before, and is generally used for some mainstream functions of iOS. Fortunately, some Linux development things were introduced during college, if you don't even know what the basic Linux terminal commands are, it's a little difficult. However, the more difficulties you have, the more things you want to learn. In addition to accumulating knowledge, you will also learn more and more ideas to handle problems, and your abilities will naturally be improved, although the process is abusive, it feels amazing. PS: the first time a blog is written, the level is limited. If the content above is biased, please correct me.