确保 Sql Server 数据库中的文本字段使用特定字体
简短背景: 我终于隔离了我遇到的一个错误。问题是我的 Web 用户使用 Safari 访问我的 ASP.NET 应用程序,其内容存储的字体与所有其他用户不同。这是一个问题,因为我用来动态创建 PDF 的第 3 方应用程序仅识别 2 种字体(arial 和 times new roman),而 Safari 插入的任何字体都是不同的字体。
解决方案: 我希望做的是将 Sql Server 中的列设置为仅存储一种字体。如果这是不可能的,我可以删除这篇文章并找到另一个解决方案,但这个解决方案将是最有效的。
编辑: 我忘记了一件有趣的事。唯一似乎设置了错误字体的字符是单引号 ' 和双引号 "
Short Background:
I finally isolated a bug I'm having. The problem is web users of mine who are accessing my ASP.NET application using Safari are storing their content in a different font than all other users. This is a problem because the 3rd party application I am using to dynamically create PDF's only recognizes 2 fonts (arial and times new roman), and whatever Safari inserts is a different font.
Solution:
What I am hoping to do is set the column in Sql Server to store only one font. If this is not possible I can delete this post and find another solution, but this one would be the most efficient by a mile.
EDIT:
One thing I forgot that is interesting. The only characters that seem to have the wrong font set on them are the single-quote ' and double-quote "
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该问题与字体无关。数据库文本字段不存储字体信息,除非您专门存储 RTF 或 HTML 编码文本。
问题是有多种类型的引号。通常在编程中,我们处理单引号的 char 39 和双引号的 char 34。
文字处理程序(显然还有 Safari)通常会自动用卷曲版本替换这些引号。请参见下表:
如果要在数据库中标准化这些值,请在插入数据库之前将卷曲版本替换为普通版本。
The problem has nothing to do with fonts. Database text fields don't store font information unless you're specifically storing RTF or HTML encoded text.
The problem is there are multiple types of quotes. Typically in programming we deal with char 39 for a single quote and char 34 for a double quote.
Word processors (and apparently Safari) often replace these quotes automatically with curly versions. See the table below:
If you want to standardize these values in your database, replace the curly versions for the plain versions prior to inserting into the database.
我唯一能想到的是你的“其他字体”用户以某种方式传递了不同的信息,并且文本不被理解为 ASCII。
SQL Server只存储字符串,不会存储字体信息。但是...尝试将数据存储在 varbinary(max) 列中,看看这是否适合您。您绝对可以在 varbinary(max) 中放入任何内容...如果这不能解决您的解决方案(我怀疑它会),您可以继续并找出 ASP.Net 应用程序的问题所在。
The only thing I can think of is your 'other font' users are somehow passing different information in, and the text isn't being understood as ASCII.
SQL Server only stores strings, it won't store font information. But... try storing the data in a varbinary(max) column and seeing if that works for you. You can put absolutely anything in varbinary(max)... and if that doesn't solve your solution (as I doubt it will), you can move on and work out what's wrong with your ASP.Net application.