×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Displaying £ signs

Displaying £ signs

Displaying £ signs

(OP)
I am having problems on a particular domain with displaying £ signs.
I believe it is a server issue but the ISP assures me that their servers are working fine.
I have 2 domains with this ISP and one displays £ signs OK but the other one doesn't.
On every other server I have ever used

CODE

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use warnings;
use strict;
use CGI;
use DBI;
print "Content-type: text/html\n\n";	# prepare for HTML output
print "£<br>"; 
prints a £ sign no problem.
On one particular server it prints a square box.
In every case, it is printing character 163 but why should there be a difference unless something on the server is different?

Keith
www.studiosoft.co.uk

RE: Displaying £ signs

Hi

Maybe that particular web server adds a charset that not matches your script's charset. For example in Apache the AddDefaultCharset forces the inclusion of a specified charset name when the Content-type HTTP response header specifies text/plain or text/html without charset. So try to specify it explicitly :

CODE --> Perl ( fragment )

print "Content-type: text/html; charset=utf-8\n\n";	# prepare for HTML output 

Or another possibility to try to turn off the addition of default charset :

CODE --> .htaccess

AddDefaultCharset Off 

Feherke.
feherke.ga

RE: Displaying £ signs

(OP)
I have tried all of the above and a lot more besides, ie. specifying the charset in the htaccess.

My main gripe is that none of this witchcraft should be necessary as by default a £ should be displayed as a £. It has been this way on all the shared hosting and virtual servers I have had dealings with.
The Help desk at the ISP have resorted to Google to find a solution - it would be laughable if it hadn't taken them many weeks to get to this point and one fix they suggested was to add the following code to the declarations in the Perl file.

CODE

use open ( ":encoding(UTF-8)", ":std" ); 

In the working script, as opposed to the simple test example above, I read content from a text file and all £ signs are converted to diamonds with question marks in them. After adding the encoding declaration above, all £ signs were converted to their HEX equivalent.

Keith
www.studiosoft.co.uk

RE: Displaying £ signs

(OP)
After further tests I can confirm it is not a Perl issue.
The simple task of downloading a text file, containing £'s, results in different displays on the 2 servers.

Keith
www.studiosoft.co.uk

RE: Displaying £ signs

Hi

Can you post the HTTP response headers sent to the browser ?

Feherke.
feherke.ga

RE: Displaying £ signs

(OP)
Not sure if this is the correct info but I got them from an online tool.
Is there a better way to capture them?

CODE

HTTP/1.1 200 OK   
  Date: Fri, 11 Jul 2014 09:05:17 GMT   
  Server: Apache/2.2.15 (CentOS)   
  Last-Modified: Sat, 05 Jul 2014 08:28:07 GMT   
  ETag: "5d3704-49f-4fd6e057ab444"   
  Accept-Ranges: bytes   
  Content-Length: 1183   
  Connection: close   
  Content-Type: text/plain; charset=UTF-8 

Keith
www.studiosoft.co.uk

RE: Displaying £ signs

Hi

Interesting. If the file is indeed UTF-8 (*), then it should be served correctly with this header.

(*) I usually open the file with Yudit and if it looks correctly, it is certainly unicode.

Quote (Keith)

Not sure if this is the correct info but I got them from an online tool.

Is there a better way to capture them?
Should be Ok that way too. I prefer local tools. What I used so far :

Feherke.
feherke.ga

RE: Displaying £ signs

(OP)
I can't mess with this any more so I have changed all incoming chr(163)'s into the &pound; entities.
I find it strange that this new server supplied by a UK ISP cannot display £ signs by default.
Is this problem with £ signs widespread and I have just been lucky so far or is this ISP simply worth avoiding?

Keith
www.studiosoft.co.uk

RE: Displaying £ signs

(OP)
Adding a default charset to the .htaccess file has meant that ordinary web pages display £ signs correctly.
Reading the contents of the same web pages via a script in the cgi-bin corrupts the file.
Is it possible that the charset of the cgi-bin is somehow set to an unchangeable value?

Keith
www.studiosoft.co.uk

RE: Displaying £ signs

I don't suppose the data is coming from MS SQL Server is it?

Unicode data from MS SQL and DBI don't mix well and you have to encode them using codepage 1252

CODE

my $unicode = encode("cp1252", $my_dbi_data); 

I spent a lot of time liaising with DBD::ODBC maintainer of the DBI project as I had a whole host of corrupt chars when outputting MS SQL to the browser direct from DBI before encoding it.

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Displaying £ signs

(OP)
The data is being read from a text file into a Perl script.
If I link directly to the text file from a browser, it displays the pound signs as boxes.
I tried saving the same file to a few other directories and sometimes it displays £ signs and other times it displays the boxes.
All this has become irrelevant as my client has made the decision to leave this ISP, not before time in my opinion.

Keith
www.studiosoft.co.uk

RE: Displaying £ signs

(OP)
Thanks - I had to laugh this morning as in one of the replies in the ISP's support ticket, on their own website, £ signs appear as odd symbols there too.

It seems that the problem is greater than they thought, in fact, I don't think they realised they had a problem.

Keith
www.studiosoft.co.uk

RE: Displaying £ signs

it looks like you should check your server's locale and regenerate it with locale-gen maybe to something like en_US.UTF-8 or the equivalent for GB but the UTF-8 one. Then you should restart your web and db servers. all these of course if you have ssh access on your server.
Perl internal does not realy care about the encoding of your data. So perl is never the problem.

``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI

RE: Displaying £ signs

(OP)
This was shared access with an ISP who claim to be one of the best in the country. I have been with them for a good number of years and in that time I have seen them deteriorate to a level which I find unacceptable. This issue is not an isolated incident and we have had a catalogue of disasters over the last 12 months which has forced us to move all of our sites to another ISP, a lot of work but necessary as I personally have been spending far too much time fixing things which should just work.

Keith
www.studiosoft.co.uk

RE: Displaying £ signs

I know that feeling Keith, I have just had to move provider of our POP3 mailbox hosting service, as the company I have been with for many, many years has gone seriously downhill, to the point they don't even respond to support emails anymore. I've been trialling one member on the new host provider, and so far so good. Like you say it's a lot of work to move everyone over, but necessary as we couldn't carry on with a host company who's service has become unreliable and support unreachable.

I have also had to move all members using the POP3 service onto a new DNS provider as the domain registrar was getting put on an RBL spam list every other day!

I'm sure you are like me, and have far more important things to be spending your time on other than chasing unreliable service providers who aren't providing the service you pay for!

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Displaying £ signs

(OP)
We could easily be talking about the same company although to be fair they haven't stopped offering support, they were taking up to 2 days to respond and then offering no useful assistance at all.
I feel sorry for any customers of theirs who are new to the game and do not know when the are being spun a yarn.

Keith
www.studiosoft.co.uk

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close