4

I am using classic asp and IIS7 for development.

When I enter a text with special character(£) in a textbox and do a submit. The special character received on the server side code changes to a diamond symbol with question mark in it.

The following encoding has been included

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

in the asp file.

I have also tried saving the file with "Encode in UTF-8 without BOM" format

Whereas the same file deployed on the development server works fine. The special character(£) stays intact on the server side code.

Am I missing some IIS7 setting.

sham
  • 691
  • 8
  • 28
  • You are telling the browser to output `iso-8859-1` but you are saving the file as `UTF-8`, what have you told ASP to process the file as? `<%@ CodePage = ? %>`?? At present the diamond symbol represents a mismatch in encoding, between what is expected and what is being sent. – user692942 Feb 12 '15 at 14:13
  • This page does not contain the CodePage directive – sham Feb 12 '15 at 14:16
  • In that case what is IIS defaulting to the ASP settings for that web application? (I would guess 65001 which is UTF-8). – user692942 Feb 12 '15 at 14:17
  • Where in IIS7 do I look for this setting? – sham Feb 12 '15 at 14:19
  • 1
    This might help, this isn't the first time I've answered this question - [SO - convert utf-8 to iso-8859-1 in classic asp](http://stackoverflow.com/a/17680939/692942) – user692942 Feb 12 '15 at 14:20
  • The same file without any change works fine after deploying on IIS7 testing environment. – sham Feb 12 '15 at 14:29
  • In which case the "testing" and "production" environments are not configured the same, that link will help you diagnose the problem. Try running a simple page on the "testing" environment with just `Response.Write Response.Charset` and see what is returned. – user692942 Feb 12 '15 at 14:31
  • Let's continue this discussion in [chat](http://chat.stackoverflow.com/rooms/70794/discussion-between-sham-and-lankymart). – user692942 Feb 12 '15 at 14:48

2 Answers2

0

At times, you may see a question mark (?) character or a box where a character is supposed to appear.

Codepage conversion issues

When a character is replaced by a question mark (?) character, this is an indication that a codepage conversion issue, has occurred. The question mark (?) is a default character for the codepage conversion and basically means that the operating system does not know how to handle the character value and convert it. It replaces the character value with a question mark (?). This could mean that the character has an invalid value for the codepage or that the codepage that is needed for the conversion is not installed.

Font conversion issues

When a character is replaced by a box, this is an indication that a font conversion issue has occurred. This occurs on the client side when the client does not have the correct font installed to display this character correctly. For example, when a character is from the Japanese charset, and the client does not have the Japanese fonts installed, the Japanese character is displayed as a box.

sham
  • 691
  • 8
  • 28
  • No, it was some intermittent issue, happened and happens from only one machine, really strange... – sham Feb 25 '15 at 19:20
  • 1
    Did you try setting `Response.CharSet = "ISO-8859-1"` and `Response.CodePage = 28591` as I suggested in the [chat](http://chat.stackoverflow.com/transcript/message/21504804#21504804)? – user692942 Feb 25 '15 at 19:30
  • The problem was, unicode characters worked on a system without making the code changes. – sham Feb 25 '15 at 19:35
  • Yes, but you are missing the point. The code should have something to tell the browser what encoding to expect, without it the browser has to make a "best guess". This could be different across browsers and operating systems. The fact it works on one doesn't mean it will work on another until you fix the assumption that is being made. At least test it to see if the problem goes away before assuming you have all the bases covered. – user692942 Feb 25 '15 at 19:54
0

Define this in your head section for each page

META http-equiv=Content-Type content="text/html; charset=iso-8859-1

Before I did this, it was set to:

meta charset=utf-8

which was leaving me with the ? inside the diamond for characters like the copyright symbol etc.