Comments (7)
如果你的ssh服务器默认编码utf-8 (Linux系统一般都默认使用这个编码),
而你使用vim处理gbk编码的中文文件, 简单的方法就是,
打开gbk文件
$ vim gbk.txt
使用编码gbk
:e ++enc=gbk
from webssh.
@huashengdun
多谢。实际我是先找到了https://github.com/xsank/webssh.git, 后来发现这个project不支持中文非utf-8编码,和这个问题类似 xsank/webssh#10. 如果ssh服务器上有一个文件名是中文gbk编码的文件,通过webssh终端登录这个服务器的时候,终端会报connection close, 查看具体报错信息为“could not decode a text frame as utf-8”。能不能指导下https://github.com/xsank/webssh.git 这个project如何修改可以解决这个问题,非常感谢
from webssh.
不好意思,我对xsank/webssh这个项目不熟悉。
你应该找这个项目的作者xsank寻求帮助。
from webssh.
@anythingwhat
如果ssh服务器上有一个文件名是中文gbk编码的文件,通过webssh终端登录这个服务器的时候,终端会报connection close, 查看具体报错信息为“could not decode a text frame as utf-8”。
服务器上存有中文gbk编码的文件,登录服务器不会导致“终端会报connection close”。
导致客户端wesocket断开,是因为你在terminal运行了类似cat之类的查看命令。
服务端解决方法如下:
cat gbk.txt | iconv -f gbk -t utf-8
在我的这个应用中,在js里有了两个函数,wssh.set_encoding(encoding), wssh.reset_encoding()。
客户端解决方法如下:
1.设置客户端使用gbk编码,在console中运行,
wssh.set_encoding('gbk');
- 然后你可以在客户端terminal中可直接运行,能正确显示gbk文件
cat gbk.txt
- 恢复使用服务器的默认编码,在console中运行,
wssh.reset_encoding();
from webssh.
@huashengdun ,非常感谢
from webssh.
@huashengdun 再请教下。能不能在程序里自动处理、支持查看gbk编码的中文文件,这样显式的用cat gbk.txt | iconv -f gbk -t utf-8或者wssh.set_encoding不方便
from webssh.
可以先对文件检测编码,然后使用检测获的编码对文件读取成文本文件。
对每个文件都这样做,估计会影响后台效率,尤其大文件。
然后最终程序还要把你的文件文件用用utf-8编码,最后网络传输。
from webssh.
Related Issues (20)
- Meet "XSRF cookie does not match POST argument" On codesandbox.io
- SSH connections use proxies, such as HTTP, https, and socket5, which can be configured separately for each connection
- browser console always throw errors: main.js:807 Uncaught TypeError: event.data.split is not a function
- Closing worker with reason: worker recycled HOT 3
- Setting font spacing? HOT 1
- Is there a way to send referrer in upgrade header?
- 请问能不能在跳转到webssh后,自动执行一下初始化的操作?比如自动配置一些环境变量?
- is it possible to completely disable http server?
- Can i avoid log-in? I don't want to input username password passphrase everytime HOT 1
- XSS injection in webssh hostname field HOT 1
- 汉字显示乱码
- Getting Error No existing session
- Authentication Failure with OpenSSH 9: Bad authentication type HOT 1
- Closing worker {workerId} with reason: worker recycled
- Connection to 127.0.0.1:8000 is not allowed.
- webssh登录页hostname填入外网IP时,就提示bad host key,填入localhost就可以正确登录,请问hostname为什么不能用外网IP?
- Is there a good way to auth by SSH_AUTH_SOCK(ssh agent)
- url中密码只能是base64吗? 有没有别的加密方式
- Issue with pytest 8.2.0 and tornado async task HOT 2
- webssh在外接显示屏下显示不全
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webssh.