断裂和非断裂空间ASCII字符之间的区别

发布于 2025-02-09 12:39:05 字数 134 浏览 0 评论 0原文

我在JavaScript中有两个相同的字符串,并有一些空间。当我使用str.CharCodeat(n)打印ASCII值时,它将值显示为32和160。我搜索了值,它显示了我为破坏和非断裂空间。因此,任何人都可以解释这是什么行为。

I have two identical strings in javascript with some spaces. When I printed the ascii values by using str.charCodeAt(n) it is showing the values as 32 and 160. I googled the values and it is showing me as breaking and non breaking spaces. So can anybody explain what is this behaviour.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

七秒鱼° 2025-02-16 12:39:05

普通(断裂)空间和非断裂空间之间的区别在于,文本显示和排版软件不应插入自动线路断开以代替非破坏空间。 (好像非破裂的空间将其前后的单词加入了一个无法命名的单词。)相比之下,普通空间被视为折断线路的可能位置。

话虽如此,代码160实际上超出了常规(7位)ASCII的范围。 160作为非破坏空间(或nbsp)字符的解释来自Latin1(ISO8859-1)字符集。 (在扩展ASCII中,nbsp字符的代码为255!!)

The difference between a normal (breaking) space and a non-breaking space is that text display and typesetting software should not insert an automatic line break in place of a non-breaking space. (It is as if the non-breaking space joins the words before and after it into an unsplittable word.) By contrast, a regular space is treated as a possible place to break a line.

Having said that, the code 160 is actually outside of the range of regular (7-bit) ASCII. The interpretation of 160 as a non-breaking space (or NBSP) character comes from the Latin1 (ISO8859-1) character set. (In Extended ASCII, the code for the NBSP character is 255!)

References:

日裸衫吸 2025-02-16 12:39:05

非破坏空间是不会闯入新线路的空间。
由非破裂空间隔开的两个单词将粘在一起而不会闯入新线路。

另一方面,破裂空间将破裂。

A non-breaking space is a space that will not break into a new line.
Two words separated by a non-breaking space will stick together and not break into a new line.

Breaking spaces on the other hand will break.

日久见人心 2025-02-16 12:39:05

有趣的事实:在空间上运行的SQL函数(例如,Ltrim())仅在断裂空间而不是在非断裂空间上运行。为了让他们处理您的角色字符串(例如,如果您导入某人使用了非破坏空间的数据),则需要先将其转换为断路空间。

Fun fact: SQL functions that operate on spaces (for example, LTRIM()) only operate on breaking spaces, not on non-breaking spaces. To get them to work on your character strings (say, for example, if you imported data where someone had used non-breaking spaces), you need to convert them to breaking spaces first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文