Html Zalgo 文本如何工作?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6579844/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 09:23:19  来源:igfitidea点击:

How does Zalgo text work?

htmlunicodezalgo

提问by Mike

I've seen weirdly formatted text called Zalgo like below written on various forums. It's kind of annoying to look at, but it really bothers me because it undermines my notion of what a character is supposed to be. My understanding is that a character is supposed to move horizontally across a line and stay within a certain "container". Obviously the Zalgo text is moving vertically and doesn't seem to be restricted to any space.

我在各种论坛上看到过类似下面这样的名为 Zalgo 的奇怪格式的文本。看起来有点烦人,但它真的让我烦恼,因为它破坏了我对角色应该是什么的概念。我的理解是,角色应该水平移动穿过一条线并停留在某个“容器”内。显然,Zalgo 文本是垂直移动的,似乎不受任何空间的限制。

Is this a bug/flaw/exploit/hack in Unicode? Are these individual characters with weird properties? "What" is happening here?

这是 Unicode 中的错误/缺陷/漏洞利用/黑客攻击吗?这些个人角色是否具有奇怪的属性?“什么”在这里发生?


H??????????????o?????????????w?????????????? ???????d??????????o??????????e?????????????s?????????? ???????????????Z??????????a?????????l?????????g?????o??????????? ???????????t?????????e??????????x??????????????t??????????? ??????w?????????????o??????????????r???????k???????????????????????



如何?????????????????????做?????? ??????????????????Z??????????a?????????l?????????g??? ??o????????????? ???????????文本?? ????????? ??????工作?????? ?????????????????????


采纳答案by Jukka K. Korpela

The text uses combining characters, also known as combining marks. See section 2.11 of Combining Characters in the Unicode Standard(PDF).

文本使用组合字符,也称为组合标记。请参阅Unicode 标准(PDF) 中的组合字符的第 2.11 节。

In Unicode, character rendering does not use a simple character cell model where each glyph fits into a box with given height. Combining marks may be rendered above, below, or inside a base character

在 Unicode 中,字符渲染不使用简单的字符单元模型,其中每个字形适合具有给定高度的框。组合标记可以呈现在基本字符的上方、下方或内部

So you can easily construct a character sequence, consisting of a base character and “combining above” marks, of any length, to reach any desired visual height, assuming that the rendering software conforms to the Unicode rendering model. Such a sequence has no meaning of course, and even a monkey could produce it (e.g., given a keyboard with suitable driver).

因此,假设渲染软件符合 Unicode 渲染模型,您可以轻松构建由基本字符和“组合上方”标记组成的任意长度的字符序列,以达到任何所需的视觉高度。这样的序列当然没有意义,甚至猴子也可以产生它(例如,给定带有合适驱动程序的键盘)。

And you can mix “combining above” and “combining below” marks.

您可以混合使用“上面组合”和“下面组合”标记。

The sample text in the question starts with:

问题中的示例文本以:

回答by Matas Vaitkevicius

Zalgo text works because of combining characters. These are special characters that allow to modify character that comes before.

Zalgo 文本由于组合字符而起作用。这些是允许修改之前出现的字符的特殊字符。

enter image description here

在此处输入图片说明

OR

或者

y + ̆ = y̆ which actually is

y + ̆ = y̆ 实际上是

y + ̆ = y̆

Since you can stack them one atop the other you can produce the following:


由于您可以将它们一个一个堆叠在一起,因此您可以生成以下内容:


y̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆

y̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆

which actually is:

这实际上是:

y̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆

The same goes for putting stuff underneath:


将东西放在下面也是如此:


y̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆

y̰̰̰̰̰̰̰̰̰̰̰̰̰̰̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆



that in fact is:



这实际上是:

y̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆̆

In Unicode, the main block of combining diacritics for European languages and the International Phonetic Alphabet is U+0300–U+036F.

在 Unicode 中,组合欧洲语言和国际音标变音符号的主要块是 U+0300–U+036F。

More about it here

更多关于这里

To produce a list of combining diacritical marks you can use the following script (since links keep on dying)

要生成组合变音符号列表,您可以使用以下脚本(因为链接不断消失)

for(var i=768; i<879; i++){console.log(new DOMParser().parseFromString("&#"+i+";", "text/html").documentElement.textContent +"  "+"&#"+i+";");}

Also check em out



也检查一下



Mͣͭͣ̾ Vͣͥͭ͛ͤͮͥͨͥͧ̾

Mͣͭͣ̾ Vͣͥͭ͛ͤͮͥͨͥͧ̾