插入特殊字符、标题分隔符
我将这样做,将网页标题
我既有标题又有标题分割器..
像这样
page.com •
: page.com 是标题,• 是拆分器
。通过将拆分器• 插入数据库,我几乎没有遇到任何问题。我尝试按原样插入它, • 并通过html 代码•
。
第一次尝试有• 结果是?在我的 varchar 字段中, 第二次尝试使用 •
是在网页标题中它也显示为 •
而不是实际的图标/符号。
我该如何解决这个问题并让它接受字符,这样它们就不会变成这样?或者 ??
我应该使用除 varchar 以外的其他列类型吗?
I am going to do so the webtitle <title>
is stored in the db, so you can change it without editing file..
I have both the title and a title splitter..
Like this:
page.com •
the page.com is the title and the • is the splitter
Im having little issue by inserting the splitter, • into the database. I tried insert it as it is, • and by the html code •
.
The first try by having • is that it turns out as ? in my varchar field,
Second try by having •
is that in the webtitle it shows also as •
and not the actual icon/symbol.
How can i fix this and have it accept chars so they dont turn out as ? or ??
Should i use another columntype than varchar maybe?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先,
title
不允许 html-entities恕我直言,你应该存储作为
•
并且仅在输出 HTML 时将其操作/转换为其原始字符
first,
title
does not allow html-entitiesimho, you should store as
•
and only manipulate/convert that into its original character when you outputing HTML
•
实际上应该可以解决问题。查看加载到浏览器的最终 html 代码。
可能有一些转义字符
•
should actually do the trick.look at your final html code that loaded to the browser.
may be there are some escaping characters
这正是您应该存储它的方式。我不确定为什么您的浏览器不显示它。我刚刚用 Mozilla 进行了测试,它对我来说工作得很好。
That is exactly the way you should store it. I'm not sure why your browser is not displaying it. I just tested with Mozilla and it work's fine for me.
Varchar 应该没问题。 。 。
当您发送数据或从数据库收集数据时,您是否通过诸如 htmlspecialchars() 之类的方式发送数据?确保您实际发送的是字符串,而不是字符串的剥离版本。
Varchar should be fine. . .
When you send your data, or gather it from your DB, are you sending it through anything like htmlspecialchars() ? Make sure you're actually sending the string, and not a stripped version of the string.