X3.4发帖特色字符不显示是哪里没有设置恰当吗 New
X3.4发帖特色字符不显示是哪里没有设置恰当吗发帖后就显示代码
1 贡献最佳答案
尝试方法:在输出时还原实体
在显示帖子内容时,将 📌 还原为真正的 Unicode 符号。
修改文件:/source/function/function_discuzcode.php
在函数 discuzcode 的 return 语句之前插入还原逻辑。
定位方式
找到函数 discuzcode 的最后几行(约第 215-220 行):
return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ''), array(' ', ' ', ' '), $message));}
替换为
// ===== 新增:还原 Unicode 实体编码,使 Emoji 正常显示 ===== $message = htmlspecialchars_decode($message, ENT_QUOTES); // ======================================================== return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ''), array(' ', ' ', ' '), $message));}
位置说明:放在 return 之前,确保所有 Discuz! 的 BBcode 解析完成后再进行还原,不影响其他解析逻辑。
验证步骤
修改文件并保存 清理 Discuz! 后台缓存 打开之前显示错误的帖子,确认 Emoji 正常显示
注意事项
该修改仅影响帖子内容的显示,不改变数据库存储内容 如果后续发帖依然出现 &# 明文,说明发帖提交时已被转义,需要检查 post_newthread.php 等提交环节,但先试这个输出还原的方案
IsaacZ发表于5 天前
[*]详细答案 >
尝试方法:在输出时还原实体
在显示帖子内容时,将 📌 还原为真正的 Unicode 符号。
修改文件:/source/function/function_discuzcode.php
在函数 discuzcode 的 return 语句之前插入还原逻辑。
定位方式
找到函数 discuzcode 的最后几行(约第 215-220 行):
return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ''), array(' ', ' ', ' '), $message));}
替换为
// ===== 新增:还原 Unicode 实体编码,使 Emoji 正常显示 ===== $message = htmlspecialchars_decode($message, ENT_QUOTES); // ======================================================== return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ''), array(' ', ' ', ' '), $message));}
位置说明:放在 return 之前,确保所有 Discuz! 的 BBcode 解析完成后再进行还原,不影响其他解析逻辑。
验证步骤
修改文件并保存 清理 Discuz! 后台缓存 打开之前显示错误的帖子,确认 Emoji 正常显示
注意事项
该修改仅影响帖子内容的显示,不改变数据库存储内容 如果后续发帖依然出现 &# 明文,说明发帖提交时已被转义,需要检查 post_newthread.php 等提交环节,但先试这个输出还原的方案
怎么还在用3.4?要不要我免费帮你升级到5.0 free 谢谢,我有空改一下看 升级3.5失败无数次了,不想折腾了 大家都可以帮忙,别泄气。
X3.5可以支持 PHP8.0了 IsaacZ 发表于 2026-8-10 12:49
尝试方法:在输出时还原实体
在显示帖子内容时,将 📌 还原为真正的 Unicode 符号。 你好,请问这个还要显示这种代码呢
.ce-block { margin-bottom: 20px;}.ce-block__content,.ce-toolbar__content { /* max-width:calc(100% - 50px) */ margin-left: auto; margin-right: auto;}.ce-paragraph { line-height: 1.6em; outline: none; text-indent: 2em; font-size: 16px;}.ce-paragraph--right { text-align: right;}.ce-paragraph--center { text-align: center;}.ce-paragraph--left { text-align: left;}.ce-paragraph--justify { text-align: justify;}.ce-paragraph-text-indent { text-align: justify;}.ce-paragraph:empty::before{content: attr(data-placeholder);color: #707684;font-weight: normal;opacity: 0;}/** Show placeholder at the first paragraph if Editor is empty */.codex-editor--empty .ce-block:first-child .ce-paragraph:empty::before {opacity: 1;}.codex-editor--toolbox-opened .ce-block:first-child .ce-paragraph:empty::before,.codex-editor--empty .ce-block:first-child .ce-paragraph:empty:focus::before {opacity: 0;}.ce-paragraph p:first-of-type{ margin-top: 0;}.ce-paragraph p:last-of-type{ margin-bottom: 0;}.svg-icon { width: 1em; height: 1em;}.svg-icon path,.svg-icon polygon,.svg-icon rect { fill: #4691f6;}.svg-icon circle { stroke: #4691f6; stroke-width: 1;}.ce-block { margin-bottom: 20px;}.ce-block__content,.ce-toolbar__content { /* max-width:calc(100% - 50px) */ margin-left: auto; margin-right: auto;}.image-tool {--bg-color: #cdd1e0;--front-color: #388ae5;--border-color: #e8e8eb;}.image-tool__image { border-radius: 3px; overflow: hidden; margin-bottom: 10px;}.image-tool__image-picture { max-width: 100%; vertical-align: bottom; display: block; margin-left: auto; margin-right: auto; }.image-tool__image-preloader { width: 50px; height: 50px; border-radius: 50%; background-size: cover; margin: auto; position: relative; background-color: #cdd1e0; background-position: center center; }.image-tool__image-preloader::after { content: ""; position: absolute; z-index: 3; width: 60px; height: 60px; border-radius: 50%; border: 2px solid #cdd1e0; border-top-color: #388ae5; left: 50%; top: 50%; margin-top: -30px; margin-left: -30px; animation: image-preloader-spin 2s infinite linear; box-sizing: border-box; }.image-tool__caption::before { position: absolute !important; content: attr(data-placeholder); color: #707684; font-weight: normal; display: none; }.image-tool__caption:empty::before { display: block; }.image-tool__caption:empty:focus::before { display: none; }.image-tool--empty .image-tool__image { display: none; }.image-tool--empty .image-tool__caption, .image-tool--loading .image-tool__caption { display: none; }.image-tool .cdx-button { display: flex; align-items: center; justify-content: center;}.image-tool .cdx-button svg { height: auto; margin: 0 6px 0 0; }.image-tool--filled .cdx-button { display: none; }.image-tool--filled .image-tool__image-preloader { display: none; }.image-tool--loading .image-tool__image { min-height: 200px; display: flex; border: 1px solid #e8e8eb; background-color: #fff; }.image-tool--loading .image-tool__image-picture { display: none; }.image-tool--loading .cdx-button { display: none; }/** * Tunes * ---------------- */.image-tool--withBorder .image-tool__image { border: 1px solid #e8e8eb; }.image-tool--withBackground .image-tool__image { padding: 15px; background: #cdd1e0; }.image-tool--withBackground .image-tool__image-picture { max-width: 60%; margin: 0 auto; }.image-tool--stretched .image-tool__image-picture { width: 100%; }.image-tool__caption { text-align: center; font-size: 14px; color: #a3a3a3; }@keyframes image-preloader-spin {0% { transform: rotate(0deg);}100% { transform: rotate(360deg);}}.inline-code {background: rgba(250, 239, 240, 0.78);color: #b44437;padding: 3px 4px;border-radius: 5px;margin: 0 1px;font-family: inherit;font-size: 0.86em;font-weight: 500;letter-spacing: 0.3px;} 这是颜色标记。不想要的话,清除格式就好。 就是没有解析颜色代码 是Discuz! 内置的 BBcode 解析器无法识别这种颜色格式导致的。
根本原因
Discuz! 的 标签,其设计逻辑是对应 HTML 中 font 标签的 color 属性,只能解析标准的十六进制颜色码(如 #000000)或基本的英文颜色名(如 red、blue)。
而你使用的 rgba(0,0,0,0.9) 是一种 CSS 颜色值,它是为样式表(CSS)设计的复杂语法,远超 Discuz! 简单的 BBcode 解析能力。
因此, 这个标签在解析时失败,系统无法应用颜色,最终只输出了纯文本。预览有效,而发帖后无效,是因为预览和发帖后的解析机制不同。
根本解决方案
最彻底的解决办法是利用 function_discuzcode.php,扩展 discuzcode 函数,为 标签增加对 rgb() 和 rgba() 格式的支持。
页:
[1]