Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #24602
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: copyright symbol |
| Date | 2014-06-04 11:21 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <lmmvf6$dvf$2@dont-email.me> (permalink) |
| References | <V_adnebgvuRUPxPOnZ2dnUVZ_vudnZ2d@westnet.com.au> |
On Wed, 04 Jun 2014 14:36:26 +1000, Andrew Poulos wrote:
> I have an MS SQL Server database with a copyright symbol in a field of
> data type varchar(80). When this is read by JScript in a classic ASP and
> then displayed in the page the symbol displays as a black diamond with a
> question mark in it.
>
> If I change the page's charset from
> <meta charset="UTF-8">
> to
> <meta charset="iso-8859-1">
> the symbol correctly displays as a copyright symbol.
I'm guessing that the data stored in the sql database isn't a utf-8
copyright symbol, but rather an iso 8859-1 copyright symbol. I'm also
guessing that an iso-8859-1 copyright symbol is an illegal character in
utf-8.
> Why does changing the charset "fix" the display of the symbol?
Because it makes the browser display the symbol in the correct character
set.
> I'd rather keep the charset as UTF but I'm at a loss as to what's going
> on.
My guess would be that someone is filling in a form using windows and
you're receiving iso-8859-1 character data. This is then being put into a
database. Later it's being read from the database and placed in a
document as utf-8.
> Do I need to encode the symbol before it goes into the database?
This would need you to detect the character encoding of the input and
convert it to utf-8 (or html entities). This is probably the safest
method, as hopefully the data source provides some information as to the
encoding the data is generated with. Failing that, you can try and sniff
the incoming data to guess at the encoding. User agent strings may give
possibly useful hints.
If all the character data is between values 32 and 127 inclusive (' ' ..
'~') you can probably treat it as utf-8. Otherwise you need to determine
the encoding. This is probably something you need to do in the server
when processing the input (presumably form) data. This question probably
be,longs in a perl / php / python / cgi of some description newsgroup.
> Do I need to unescape/decode the value from the database?
This is also a possible solution. However, you may have lost track of
what the original character encoding was at this point.
--
Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
copyright symbol Andrew Poulos <ap_prog@hotmail.com> - 2014-06-04 14:36 +1000
Re: copyright symbol "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2014-06-04 08:51 +0300
Re: copyright symbol "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-04 10:37 +0200
Re: copyright symbol Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-04 11:06 +0200
Re: copyright symbol Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-04 14:34 +0200
Re: copyright symbol "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2014-06-04 15:41 +0300
Re: copyright symbol Andrew Poulos <ap_prog@hotmail.com> - 2014-06-05 10:28 +1000
Re: copyright symbol "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-05 09:12 +0200
Re: copyright symbol Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-04 11:21 +0000
csiph-web