字符串中的空格字符很奇怪,不是空格吗? [英] Weird space character in string, that's not a space?

查看:444
本文介绍了字符串中的空格字符很奇怪,不是空格吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Capistrano脚本或实际上是bash命令时遇到了麻烦,导致我的脚本失败.我不断从脚本中得到错误消息:

I've been having trouble with a Capistrano script, or in fact, a bash command that was causing my script to fail. I kept on getting errors from the script saying:

没有这样的文件或目录

No such file or directory

所以这是脚本位.

run "sudo ln -s #{shared_path}/readme.txt  #{shared_path}/readme-symlink.txt"

经过仔细检查,结果发现readme.txt和readme-symlink.txt位之间有两个空格.偶然地,我发现一个是空间,另一个是看起来像一个空间的奇怪字符,但事实并非如此.这是配置为显示空白的Sublime Text中的外观:

Upon closer inspection it turns out that there are two spaces between the readme.txt and readme-symlink.txt bits. By accident I found that one is a space, and the other is just a weird character that looks like a space, but it's not. Here's what it looks like in Sublime Text, configured to display whitespace:

请注意,在上图中,readme.txt之后只有一个点,然后是另一个"空格"

Notice how, in the above image, there is only one dot after readme.txt, and then another "space"

所以这是我的问题,这个字符到底是什么,我很困惑,有人怎么能用普通的键盘敲打它?

So here's my question, what on earth is this charachter, I'm just so confused how someone managed to get that in there by typing on a normal keyboard?

推荐答案

所以我将字符串粘贴到 http://www.asciivalue.com/index.php ,第二个空格的ASCII值为160.根据

So I pasted the string at http://www.asciivalue.com/index.php, the second space has an ASCII value of 160. According to http://www.ascii-code.com/ this is a space, but it's a non-breaking space, which I believe, the command line isn't too happy about.

删除nbsp可以修复我的脚本,我可以继续我的生活.

Removing the nbsp fixes my script, and I can go on with my life again.

我只是为创建文件的人首先在其中获得nbsp而感到困惑.

I'm just stumped about how the person that created the file got a nbsp in there in the first place.

这篇关于字符串中的空格字符很奇怪,不是空格吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆