简体   繁体   English

unicode字符的换行行为(例如🦄)?

[英]Line breaking behaviour of unicode characters (e.g. 🦄)?

Background 背景

All the following are one line, and you should see different line-breaking behavior 以下所有内容都是一行,您应该看到不同的换行符

🦄 w/equals 🦄w /等于

==============================🦄============================================================================================================ ==============================🦄=================== ================================================== =======================================

🦄 w/dots 🦄带点

..................................🦄............................................................................................................................................................................................................ ..................................🦄............... .................................................. .................................................. .................................................. .......................................

⚠️ w/both for reference ⚠️两个都作为参考

==============================⚠️======================================================================================================================================================================================================================== ==============================⚠️=================== ================================================== ================================================== ================================================== ===============================================

..................................⚠️................................................................................................................................................................................................................................................................................ ..................................⚠️............... .................................................. .................................................. .................................................. .................................................. .................................................. .......

Questions: 问题:

  1. Why does the 🦄 break the line (while, the ⚠️ does not)? 为什么🦄打破了界线(而⚠️没有)?
  2. On Chrome 63/Safari 11.0 why does wrapping in "=" cause the 🦄 to stay on the top line, while wrapping in "." 在Chrome 63 / Safari 11.0上,为什么换行“=”会使🦄保持在顶线,同时换行“。” causes the 🦄 drop down to the second line? 导致🦄下降到第二行?

Recreated in JSFiddle in the following container: 在以下容器中的JSFiddle中重新创建:

div {
  width: 200px;
  display: block;
  ...
}

It has to do with the characters' properties. 它与角色的属性有关。 Warning Sign and Equals Sign are in the line break category Alphabetic , Unicorn Face is in the category Ideographic , and Full Stop is in the category Infix_Numeric . 警告标志等号是在换行符类别中AlphabeticUnicorn Face属于Ideographic完全停止属于类别Infix_Numeric

If we consult UAX #14: Unicode Line Breaking Algorithm , we can see that ideographic characters provide line break opportunities before and after, so lines are free to break around them. 如果我们参考UAX#14:Unicode换行算法 ,我们可以看到表意字符在前后提供了换行机会,因此线条可以自由地绕过它们。 Meanwhile, alphabetic characters are supposed to “stick” together, so no line breaks should occur. 同时, 字母字符应该“粘在一起”,因此不应出现换行符。 Since ⚠ is alphabetic, it glues to the equals signs and the line simply breaks when there is no more room to expand. 由于⚠是字母的,它会粘贴到等号上,当没有更多的空间扩展时,线就会断开。 The ideographic 🦄 however allows line breaks, so the text wraps as soon as it hits the unicorn to allow more space for the equals signs, which cannot break. 然而,表意文字allows允许换行,所以文字一碰到独角兽就会包裹,为等号留出更多的空间,这些空间不会破裂。

Now, as to why full stop behaves differently than the equals sign: Infix numeric characters are supposed to glue to any numeric characters that directly follow them. 现在,至于为什么完全停止的行为与等号不同:中缀数字字符应该粘合到直接跟随它们的任何数字字符。 Since that isn't the case here, another rule applies: 由于这不是这种情况,因此适用另一条规则:

When not used in a numeric context, infix separators are sentence-ending punctuation. 如果不在数字上下文中使用,则中缀分隔符是句末标点符号。 Therefore they always prevent breaks before. 因此他们总是防止休息。

This means that the line cannot break after 🦄 since the following full stop is supposed to glue to it, so it drops down to the start of the next line instead. 这意味着在🦄之后线不能断开,因为下一个完全停止应该粘合到它,所以它下降到下一行的开头。

Keep in mind that most of these line break categories are tailorable. 请记住,大多数这些换行符类别都是可定制的。 They are default values that may be very useful for most applications, but can be overridden if different behaviour is more desirable. 它们是默认值,对于大多数应用程序可能非常有用,但如果更需要不同的行为,则可以覆盖它们。 In Firefox, for example, the line breaks before 🦄 in both the full stop and the equals sign example. 例如,在Firefox中,在完全停止和等号示例中,行在before之前断开。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在CSS类名或ID中安全地使用unicode字符(例如重音符号)吗? - Can I safely use unicode characters (e.g. accents) in CSS class names or ids? 在线对齐文本,例如顶部,底部中间 - Aligning text “on-the-line” e.g. top, bottom middle 东亚(例如中文)字符是否有基线? 它们如何与CSS中的英语保持一致? - Do East Asian (e.g. Chinese) characters have baselines? How do they align with English in CSS? Workflowy-Stylebot-有没有一种方法可以设置css标签的样式,其中特定标签/项目以xxx开头(例如“ []”或“ evernote://”字符)? - Workflowy - Stylebot - Is there a way to style css tag where a particular tag/item starts with xxx (e.g. “[ ]” or “evernote://” characters? JavaFX样式相同类型的所有节点,例如VBox - JavaFX style all nodes of the same type, e.g., VBox 如何调整嵌入式图像的大小,例如产品说明中的屏幕截图 - How to size inline images E.g. screenshots in product description 对CSS中的数据属性(例如模数)进行计算(计算) - Performing calculations (calc) on data attributes in CSS (e.g. modulus) 检测滚动条是否可见(例如在移动设备上) - Detect if scrollbar is visible (e.g. on a mobile device) Angular 9 - js 脚本不工作(例如基础或引导程序) - Angular 9 - js scripts not working (e.g. foundations or bootstrap) SCSS Mixin错误:预期为变量名(例如$ x) - SCSS Mixin Error: expected a variable name (e.g. $x)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM