空格和非空格空格字符之间的区别 [英] Difference between breaking and non breaking space ascii characters

查看:230
本文介绍了空格和非空格空格字符之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

推荐答案

正常(分隔)空间和非分隔空间之间的区别在于,文本显示和排版软件不应插入自动换行符来代替不间断的空间.(好像不间断空格将其前后的单词连接成一个不可拆分的单词.)相比之下,规则空间被视为可能的换行符.

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.

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

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!)

参考文献:

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

这篇关于空格和非空格空格字符之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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