Html 奇怪的符号出现在网站 (L SEP) 上?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41555397/
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 14:13:48  来源:igfitidea点击:

Strange symbol shows up on website (L SEP)?

htmlwordpressascii

提问by BigRedDog

I noticed on my website, http://www.cscc.org.sg/, there's this odd symbol that shows up.

我注意到在我的网站http://www.cscc.org.sg/ 上,出现了这个奇怪的符号。

enter image description here

在此处输入图片说明

It says L SEP. In the HTML Code, it display the same thing.

它说 L SEP。在 HTML 代码中,它显示相同的内容。

enter image description here

在此处输入图片说明

Can someone shows me how to remove them?

有人可以告诉我如何删除它们吗?

回答by thatguy

That character is U+2028or HTML entity code 
which is a kind of newline character. It's not actually supposed to be displayed. I'm guessing that either your server side scripts failed to translate it into a new line or you are using a font that displays it.

该字符是U+2028或 HTML 实体代码
,它是一种换行符。它实际上不应该被显示。我猜要么您的服务器端脚本未能将其转换为新行,要么您正在使用显示它的字体。

But, since we know the HTML and UNICODE vales for the character, we can add a few lines of jQuery that should get rid of the character. Right now, I'm just replacing it with an empty space in the code below. Just add this:

但是,由于我们知道字符的 HTML 和 UNICODE 值,我们可以添加几行 jQuery 来去除字符。现在,我只是在下面的代码中用一个空格替换它。只需添加这个:

$(document).ready(function() {
    $("body").children().each(function() {
        $(this).html($(this).html().replace(/
/g," "));
    });
});

This should work, though please note that I have not tested this and may not work as none of my browsers will display the character.

这应该可以工作,但请注意,我尚未对此进行测试并且可能无法工作,因为我的浏览器都不会显示该字符。

But if it doesn't, you can always try pasting your text block onto http://www.nousphere.net/cleanspecial.phpwhich will remove any special characters.

但如果没有,您始终可以尝试将文本块粘贴到http://www.nousphere.net/cleanspecial.php 上,这将删除任何特殊字符。

回答by Ramanathan

This is the solution for the 'strange symbol' issue.

这是“奇怪符号”问题的解决方案。

$(document).ready(function () {
  $("body").children().each(function() {
      document.body.innerHTML = document.body.innerHTML.replace(/\u2028/g, ' ');
  });
})

回答by Snuwerd

The jquery/js solutions here work to remove the character, but it broke my Revolution Slider. I ended up doing a search replace for the character on the wp_poststabel with Better Search Replaceplugin: https://wordpress.org/plugins/better-search-replace/

此处的 jquery/js 解决方案可以删除角色,但它破坏了我的 Revolution Slider。我最终wp_postsBetter Search Replace插件对表格上的字符进行了搜索替换:https: //wordpress.org/plugins/better-search-replace/

When you copy paste the character from a page to the plugin box, it is invisible, but it does work. Before doing DB replaces, always have a database (or full) backup ready! And be sure to uncheck the bottom checkbox to not do a dry run with the plugin.

当您将字符从页面复制粘贴到插件框时,它是不可见的,但它确实有效。在进行数据库替换之前,请始终准备好数据库(或完整)备份!并确保取消选中底部的复选框,以免对插件进行试运行。

回答by Edward Brey

Some fonts render LSas L SEP. This rendering is designed for unformatted presentations of the character, such as when viewing the raw characters of a file in a binary editor. It's not designed to be displayed in a formatted presentation such as a web page.

某些字体将LS呈现为L SEP. 此渲染设计用于字符的无格式演示,例如在二进制编辑器中查看文件的原始字符时。它不是设计为在格式化的演示文稿中显示,例如网页。

The problem is that neither the web server nor web browser are interpreting the LS as a newline. The web server could detect the LS and replace it with <br>. Such a feature would fit well with a web server that dynamically generates HTML anyway, but would add overhead and complexity to a web server that serves file contents without modification.

问题是 web 服务器和 web 浏览器都没有将 LS 解释为换行符。Web 服务器可以检测到 LS 并将其替换为<br>. 这样的特性非常适合动态生成 HTML 的 Web 服务器,但会增加无需修改即可提供文件内容的 Web 服务器的开销和复杂性。

If a LS makes its way to the web browser, the web browser doesn't interpret it as formatting. Page formatting is based on HTML tags. LF and CR are used for formatting the HTML source code only (except for <div>sections). LS and PS (paragraph separator) could in principle be used for formatting the web page, since they aren't needed for formatting the HTML source, but the HTML specification doesn't specify a rendering for them.

如果 LS 进入 Web 浏览器,Web 浏览器不会将其解释为格式。页面格式基于 HTML 标签。LF 和 CR 仅用于格式化 HTML 源代码(<div>节除外)。LS 和 PS(段落分隔符)原则上可用于格式化网页,因为它们不需要用于格式化 HTML 源代码,但 HTML 规范没有为它们指定渲染。

To replace the raw LS character with the line separation that the content creator likely intended, you'll need to replace the LS characters with HTML markup, <br>or an equivalent.

要将原始 LS 字符替换为内容创建者可能想要的行分隔符,您需要用 HTML 标记<br>或等效标记替换 LS 字符。