neekey / table-parser

A parser to parse table style output from shell
MIT License
25 stars 13 forks source link

multiple-byte characters may cause problem #4

Open neekey opened 8 years ago

neekey commented 8 years ago

I encountered terminal logs like below ( from command ps ux ):

USER     PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neekey   908  13.0  2.0  5214472 333228   ??  S    四01下午 399:38.94 /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
neekey   480  10.4  1.3  3901300 212684   ??  U    四11上午  14:11.36 /System/Library/PrivateFrameworks/CommerceKit.framework/Versions/A/Resources/storedownloadd
neekey  1022   5.0  0.1  2688408  13840   ??  S    四01下午   6:50.36 /Applications/ShadowsocksX.app/Contents/MacOS/ShadowsocksX
neekey 43640   4.0  0.9  3370460 157984   ??  S    二11上午  20:08.77 /Applications/WeChat.app/Contents/MacOS/WeChat
neekey 51311   3.6  0.7  4141496 110668   ??  Ss    1:52下午   0:43.72 /System/Library/Frameworks/WebKit.framework/Versions/A/XPCServices/com.apple.WebKit.WebContent.xpc/Contents/MacOS/com.apple.WebKit.WebContent
neekey 47734   2.5  0.6  1250660 103120   ??  S    10:07下午  28:24.81 /Applications/Steam.app/Contents/MacOS/steam_osx
neekey 52560   1.8  1.9  4074920 324268   ??  S     3:23下午   1:57.04 /Applications/Google Chrome.app/Contents/Versions/50.0.2661.86/Google Chrome Helper.app/Contents/MacOS/Google Chrome Helper --type=renderer --enable-features=Automat

First of all the two-column width Chinese characters will break the logic of coordinate calculation. And the overlap of the values of TIME and COMMAND will really confuse the algorithm I proposed here.

I think it's time to dive into the implementation of how terminals output these log tables.

Any thought or suggestion will be helpful

neekey commented 8 years ago

@vangie really did a great work by implementing this module https://github.com/vangie/east-asian-width, which can detect full-width and half-width unicode character.

WebDiamond commented 5 years ago

Hi , it is possible to kill a process by name and not pid ??

waheedsd commented 1 year ago

Hi , it is possible to kill a process by name and not pid ??

https://www.npmjs.com/package/kill-process-by-name