WXforum.net
Web Weather => Weather Website PHP/AJAX scripting => Custom Website Templates => Topic started by: W3DRM on January 13, 2018, 08:09:28 PM
-
I have struggled with this issue for a long time but haven't done anything other than occasionally try to fix it. So far, nothing seems to have worked.
As you can see in my signature graphic below, after each temperature value there should be a degree symbol (°) and then an F. Instead I see an added A character with a carat or whatever it's called, then a °F. I am thinking it has something to do with the character encoding which in our case is ISO-8859-1. I have tried entering the degree sign using ALT-0176 as well as several other codes but nothing seems to work. Everyone else who is using the wxgraphic code for their signatures seems to be working just fine so it must be something I have done to cause the issue. BTW, long ago, it used to work just fine and I haven't touched the signature graphic for a long time. The only major change I have made was to switch from VWS to WD but I don't see how that could be the cause of the problem.
Any thoughts on what might the wrong?
-
Looks like it is a capital A circumflex which would be a alt-0194, why it is being added in there I have no idea.
-
Looks like it is a capital A circumflex which would be a alt-0194, why it is being added in there I have no idea.
Could be. That character is getting added to the display graphic somehow. The code clearly reads '°F' but it comes out as °F. I'm at a loss at this point.
-
So if you remove the ° the  also disappears?, what happens if you open notepad and do a alt 0176 do you get a ° ? if you do then I would say your fonts got messed up.
-
So if you remove the ° the  also disappears?, what happens if you open notepad and do a alt 0176 do you get a ° ? if you do then I would say your fonts got messed up.
Yes, take away the ° and the  goes away too. So it has something to do with the character encoding. I've seen this before but can't remember what caused it.
-
Hi Don,
I "think" the character coding is Windows ISO 8859 ?????? It may need to be UTF-8. Either that, or I have it backwards. Been a while since I looked at that.
Yes, your template has ISO-8859-1 in it. I believe this is located in your common.php file. Try changing it to UTF-8, and see if that resolves the issue.
John
P.S. - Is there a character set setting in the wxgraphic .htx file? It's been so long since I've used that.
-
Hi Don,
I "think" the character coding is Windows ISO 8859 ?????? It may need to be UTF-8. Either that, or I have it backwards. Been a while since I looked at that.
John
If I'm correct and since I'm using the Saratoga template, I have to use SO-8859-1 for the template to work correctly. Am wondering if that is what is causing the problem. However, this has worked fine in the past and I haven't made any changes for a long time.
-
Hi Don,
Do you know what version your common.php is? I have a copy of the latest version of the Saratoga template here and the version of the common.php is 1.09 from 17-Aug-15. The UTF-8 conversion features for ISO-8859-n language files, so that may not be the answer. I've seen this before, but I've slept since then.
-
Hi Don,
Do you know what version your common.php is? I have a copy of the latest version of the Saratoga template here and the version of the common.php is 1.09 from 17-Aug-15. The UTF-8 conversion features for ISO-8859-n language files, so that may not be the answer. I've seen this before, but I've slept since then.
Yes, same version here (1.09). As you said, I've too have been sleeping and can't remember what caused this same issue in the past. I think Ken knew what to do but I can't find any reference to it. I've searched the forum extensively but if the answer is there, it's very elusive.
-
Don,
In your config.txt for wxgraphic.php, you do have $degree_units = '°F';
which is in ISO-8859-1.
You'll likely need to add to your php.ini in your document root default_charset = "ISO-8859-1"
As of PHP 5.6+, PHP changed from internal coding of ISO-8859-1 to UTF-8. The GD routines (which draw the text on the image) use the internal PHP coding for the characters, so the ISO-8859-1 spec for your $degree_units is written as UTF-8 (unless the default_charset is set to ISO-8859-1)
Yes, the default charset for all the Saratoga templates is ISO, not UTF-8 (unless forced by a per-page spec to be UTF-8).
Best regards,
Ken
-
Don,
In your config.txt for wxgraphic.php, you do have $degree_units = '°F';
which is in ISO-8859-1.
You'll likely need to add to your php.ini in your document root default_charset = "ISO-8859-1"
As of PHP 5.6+, PHP changed from internal coding of ISO-8859-1 to UTF-8. The GD routines (which draw the text on the image) use the internal PHP coding for the characters, so the ISO-8859-1 spec for your $degree_units is written as UTF-8 (unless the default_charset is set to ISO-8859-1)
Yes, the default charset for all the Saratoga templates is ISO, not UTF-8 (unless forced by a per-page spec to be UTF-8).
Best regards,
Ken
Made the change to the php.ini file as indicated but, I don't see any change at all. However, I also noticed that my .htaccess file has the following line in it "AddType x-mapp-php5 .php". Could this possibly have anything to do with the issue? And, since I am running PHP 7.1.13 does that specific line in the .htaccess file need to be changed?
-
The default_charset = "ISO-8859-1" line goes in a php.ini in your document root and it should override the default set in the master php.ini.
If it doesn't, add a line to the config.txt file of
ini_set('default_charset','ISO-8859-1');
The .htaccess line (AddType) just serves to connect .php pages to a PHP processor. I'd try commenting that one out with
#AddType x-mapp-php5 .php
It may be left-over from a prior PHP implementation at your hoster.
-
The default_charset = "ISO-8859-1" line goes in a php.ini in your document root and it should override the default set in the master php.ini.
If it doesn't, add a line to the config.txt file of
ini_set('default_charset','ISO-8859-1');
The .htaccess line (AddType) just serves to connect .php pages to a PHP processor. I'd try commenting that one out with
#AddType x-mapp-php5 .php
It may be left-over from a prior PHP implementation at your hoster.
Okay, I commented-out the AddType... line in my .htaccess file. Then, I added the ini_set... line to my config.txt file as you suggested. However, still no change in the signature content.
-
Ummm.. in http://www.carsonvalleyweather.com/config.txt, I don't see an ini_set() at the top of the file (or anywhere in it) :roll:
-
Ummm.. in http://www.carsonvalleyweather.com/config.txt (http://www.carsonvalleyweather.com/config.txt), I don't see an ini_set() at the top of the file (or anywhere in it) :roll:
That's because I don't use config.txt. I have attached the following files that I use:
- .htaccess
- php.ini
- wxgraphic.php
- wxgraphic-config.txt
The php, ini and .htaccess filenames have been appended with .txt so they can be uploaded.
-
Ok.. that's understandable. I was just using the file names the stock script used :) YIour wxgraphic-config.txt script does contain the correct ini_set().
So.. the issue (in your wxgraphic-config.txt) is that it is encoded in UTF-8, not ANSI. When I view it in Notepad++ and say 'Use Western, ISO-8859-1', then the line appears as $degree_units = '°F';
and that is where it coming from.
Change the file to be ANSI, and that line back to $degree_units = '°F';
and the problem should be resolved.
-
Ok.. that's understandable. I was just using the file names the stock script used :) YIour wxgraphic-config.txt script does contain the correct ini_set().
So.. the issue (in your wxgraphic-config.txt) is that it is encoded in UTF-8, not ANSI. When I view it in Notepad++ and say 'Use Western, ISO-8859-1', then the line appears as $degree_units = '°F';
and that is where it coming from.
Change the file to be ANSI, and that line back to $degree_units = '°F';
and the problem should be resolved.
Okay, need a little help trying to understand what you are saying here for a few things, mainly for future similar issues that I or others may encounter:
- How do I see the encoding and/or tell Notepad++ to "Use Western, ISO-8859-a"? Is this a macro or some other kind of formatting that I am missing?
- How do I change the file to be ANSI? I copied the code line you posted into the existing wxgraphic-config.txt file and uploaded it but saw no change so I am assuming I'm not doing one or more of the steps correctly.
-
Notepad++ has a couple o menu items:
1) Under 'Encoding, Character sets..., Western European, ISO-8859-1' displays the file in ISO-8859-1.
2) Under 'Encoding, Convert to ANSI' , 'Encoding, Encode as ANSI' should convert UTF-8 to ANSI (and remove the BOM marker from the file).
You might try avoiding the issue entirely by using $degree_units = chr(176).'F';
That is the ISO-8859-1 character code for the degree sign.
-
Notepad++ has a couple o menu items:
1) Under 'Encoding, Character sets..., Western European, ISO-8859-1' displays the file in ISO-8859-1.
2) Under 'Encoding, Convert to ANSI' , 'Encoding, Encode as ANSI' should convert UTF-8 to ANSI (and remove the BOM marker from the file).
You might try avoiding the issue entirely by using $degree_units = chr(176).'F';
That is the ISO-8859-1 character code for the degree sign.
Interesting, I didn't have the encoding tab on my Notepad++. I had recently upgraded Notepad++ to v7.5.4 and it looks like something must have gone awry with the installation. A reinstall fixed the tab issue.
I then did what you suggested and it works perfectly now!!!
Thanks for being patient with me and getting me through this knot-hole...