Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display messy code #162

Closed
git-jiadong opened this issue Aug 17, 2021 · 11 comments
Closed

display messy code #162

git-jiadong opened this issue Aug 17, 2021 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@git-jiadong
Copy link

git-jiadong commented Aug 17, 2021

No description provided.

@git-jiadong
Copy link
Author

打印日志出现乱码,应该如何恢复,目前没有找到比较好的办法,只能重启会话

@git-jiadong
Copy link
Author

image
使用其他终端操作如图不会出现乱码,但使用windterm会出现乱码

@kingToolbox
Copy link
Owner

kingToolbox commented Aug 17, 2021

Thank you. This is a known issue. But I haven't figured out how to deal with it.

First of all, not only WindTerm, all clients/terminals usually cannot print binary data directly. In other words, cat a binary file in any terminal may cause garbled characters to be displayed. This is because the TERM control sequences were not designed to be compatible with the binary sequence.

Second, some control sequences define how to switch character ses.

  • SI (\xe):
    Switch to Standard Character Set (Ctrl-O is Shift In or LS0). This invokes the G0 character set (the default) as GL. VT200 and up implement LS0.
  • SO (\xf)
    Switch to Alternate Character Set (Ctrl-N is Shift Out or LS1). This invokes the G1 character set as GL. VT200 and up implement LS1.

So when the received binary data happens to contain the control sequence to switch the character set, the terminal will switch the character set. Although it is not what the user wants, this is correct.

WindTerm set the G1 character set to DEC supplemental graphics according to the standard, so after switching, the characters are displayed as table characters. I will check what is the default G1 character set defined by other terminals.

In dealing with binary sequences, WindTerm is indeed a little less robust than other clients. Because unlike other clients that use hard-coded finite automata machines to parse control sequences, WindTerm uses a configurable finite automata machine that makes it very easy to extend terminal emulators (terminal/terms/*.term).

The solution after the garbled is displayed is also very simple, just enter the echo -e \xf you mentioned. I will provide a better way to circumvent or solve this problem.

@git-jiadong
Copy link
Author

kingToolbox, 感谢你的解答,因为我喜欢使用WindTerm看日志,你的高亮出路做得很好。但是因为我在调试看日志的时候避免不了程序日志会出现\xf。我是否能修改(terminal/terms/*.term)来解决我实时看日志乱码的问题呢。如果可以能否提供修改的方法。非常感谢你。我将会在公司推广你的软件,让更多同事来使用,因为这是一款非常棒的终端。非常感谢!

@kingToolbox
Copy link
Owner

Yes, you can. Because the character set switch is caused by \xe or \xf in the log being parsed as the control sequence SI or SO. One of the temporary solutions is to prohibit WindTerm from parsing \xe and \xf. As I mentioned above, WindTerm uses a configurable finite automata machine that makes it very easy to customize terminal emulator, so you can just follow the steps below.

  • According to the TERM of your current session, find the corresponding configuration file. For example, if your current TERM in the session property dialog is xterm-256color, then open the terminal/terms/xterm-256color.term file.
  • Find and delete the following two lines:
 		| (?<ShiftLockingOne>                            \\x0e) # SO
		| (?<ShiftLockingZero>                           \\x0f) # SI
  • Restart WindTerm

You will find that \xe is displayed as SI and \xf is displayed as SO, but the character set will no longer be switched.

Of course, this is only a temporary solution, and the normal character set switching feature will also been removed, such as the table can no longer be drawn correctly. But at least it works, and I will fix this problem in WindTerm_2.2.x version. Please stay tuned, thank you.

@kingToolbox kingToolbox self-assigned this Aug 17, 2021
@kingToolbox kingToolbox added the bug Something isn't working label Aug 17, 2021
@git-jiadong
Copy link
Author

kingToolbox thank you。我找到了临时解决方案。使用awk过滤要输出到终端的\xe,当我打印日志的时候。

adb shell tail -F /tmp/my.log | sed "s/\\x0e//g"

这样我就能正常的工作看日志了。
期待你的新版本

@kingToolbox
Copy link
Owner

If you use the Linux command, you can also try strings:

strings -1 /tmp/my.log 

@git-jiadong
Copy link
Author

感谢你的建议

@kingToolbox
Copy link
Owner

Hi, I just released WindTerm_2.2.0_Prerelease_1 and added the Reset Character Set feature. If you encounter this problem again, you only need to simply execute the Right click menu - Reset - Reset Character Set menu item to restore the normal display. You can download and use it. Thank you.

@git-jiadong
Copy link
Author

Thank, long-expected

@kingToolbox
Copy link
Owner

Ok, this issue has been fixed and will be closed. Welcome to continue submitting new feature requests and bugs, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants