断裂和非断裂空间ascii字符之间的区别(Difference between breaking and non breaking space ascii characters)

编程入门 行业动态 更新时间:2024-10-22 08:12:40
断裂和非断裂空间ascii字符之间的区别(Difference between breaking and non breaking space ascii characters)

我在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.

最满意答案

正常(断开)空间和不间断空间之间的区别在于文本显示和排版软件不应插入自动换行符代替不间断空格。 (就好像不间断的空间将它之前和之后的单词连接成一个不可分割的单词。)相比之下,常规空间被视为打破一条线的可能位置。

话虽如此,代码160实际上在常规(7位)ASCII范围之外。 将160解释为非中断空格(或NBSP )字符来自Latin1(ISO8859-1)字符集。 (在扩展ASCII中, NBSP字符的代码是255 !)

参考文献:

“不间断的空间” (维基百科) ASCII和扩展ASCII代码图表 “拉丁语-1(ISO8859-1)字符集”

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:

"Non-breaking space" (Wikipedia) ASCII and Extended ASCII code charts "The Latin-1 (ISO8859-1) Character Set"

更多推荐

本文发布于:2023-08-07 17:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465088.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符   区别   空间   ascii   characters

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!