views:

59

answers:

2

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 "

+1  A: 

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.

Rob Farley
Rob, I remembered after reading your answer that it is specifically two characters that seem to have the font stuck on them. I edited the question to mention single-quotes and double-quotes. Maybe Macs use a different code for those two characters.
Justin C
Yeah - I'm guessing that it's writing a character that isn't part of the ASCII set. Perhaps you should consider nvarchar instead of varchar. nvarchar allows Unicode characters, which should cover you. But each character then takes 2 bytes, so consider this before making the change.
Rob Farley
I'm using "text", not "nvarchar" or "varchar"
Justin C
text uses varchar... try ntext.
Rob Farley
Also worth noting that using the `text` type is no longer recommended, that `varchar(max)`. Similarly for `ntext` and `nvarchar(max)` and `image` and `varbinary(max)`.
Rob Farley
+2  A: 

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:

Char    Value
34      Plain double quote
39      Plain single quote (apostrophe)
145     Curly left single quote
146     Curly right single quote
147     Curly left double quote
148     Curly right double quote

If you want to standardize these values in your database, replace the curly versions for the plain versions prior to inserting into the database.

Sam