Author Topic: WXGRAPHIC problem - can't display degree symbol correctly  (Read 547 times)

0 Members and 1 Guest are viewing this topic.

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3306
    • Carson Valley Weather
WXGRAPHIC problem - can't display degree symbol correctly
« 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?
Don - W3DRM - Minden, Nevada --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KRNO2
Davis Wireless VP2, WD 10.37S70,
StartWatch, VirtualVP, VPLive, , Win10 Pro
--- Logitech HD Pro C920 webcam
--- RIPE Atlas Probe - 32849

Offline WA7FWF

  • Contributor
  • ***
  • Posts: 111
  • Blitzortung 1196
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #1 on: January 13, 2018, 08:27:26 PM »
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.

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3306
    • Carson Valley Weather
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #2 on: January 13, 2018, 08:32:14 PM »
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.
Don - W3DRM - Minden, Nevada --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KRNO2
Davis Wireless VP2, WD 10.37S70,
StartWatch, VirtualVP, VPLive, , Win10 Pro
--- Logitech HD Pro C920 webcam
--- RIPE Atlas Probe - 32849

Offline WA7FWF

  • Contributor
  • ***
  • Posts: 111
  • Blitzortung 1196
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #3 on: January 13, 2018, 08:50:35 PM »
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.

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3306
    • Carson Valley Weather
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #4 on: January 13, 2018, 10:07:41 PM »
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.
Don - W3DRM - Minden, Nevada --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KRNO2
Davis Wireless VP2, WD 10.37S70,
StartWatch, VirtualVP, VPLive, , Win10 Pro
--- Logitech HD Pro C920 webcam
--- RIPE Atlas Probe - 32849

Offline sacreyweather

  • Echo Valley Weather
  • Forecaster
  • *****
  • Posts: 1631
    • Echo Valley Weather
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #5 on: January 13, 2018, 10:20:38 PM »
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.
« Last Edit: January 13, 2018, 10:24:43 PM by sacreyweather »
CWOP: D2073, GR2AE, GR3, Cumulus, PWSweather,  CoCoRaHS: AR-SL-23  

Saline Weather on Twitter
Blitzortung Station 1387

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3306
    • Carson Valley Weather
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #6 on: January 13, 2018, 10:24:54 PM »
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.
Don - W3DRM - Minden, Nevada --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KRNO2
Davis Wireless VP2, WD 10.37S70,
StartWatch, VirtualVP, VPLive, , Win10 Pro
--- Logitech HD Pro C920 webcam
--- RIPE Atlas Probe - 32849

Offline sacreyweather

  • Echo Valley Weather
  • Forecaster
  • *****
  • Posts: 1631
    • Echo Valley Weather
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #7 on: January 13, 2018, 10:34:57 PM »
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.
CWOP: D2073, GR2AE, GR3, Cumulus, PWSweather,  CoCoRaHS: AR-SL-23  

Saline Weather on Twitter
Blitzortung Station 1387

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3306
    • Carson Valley Weather
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #8 on: January 13, 2018, 11:32:34 PM »
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 - W3DRM - Minden, Nevada --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KRNO2
Davis Wireless VP2, WD 10.37S70,
StartWatch, VirtualVP, VPLive, , Win10 Pro
--- Logitech HD Pro C920 webcam
--- RIPE Atlas Probe - 32849

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 6507
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #9 on: January 14, 2018, 03:08:25 PM »
Don,
In your config.txt for wxgraphic.php, you do have
Code: [Select]
$degree_units = 'F';
which is in ISO-8859-1.

You'll likely need to add to your php.ini in your document root
Code: [Select]
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
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3306
    • Carson Valley Weather
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #10 on: January 14, 2018, 03:37:59 PM »
Don,
In your config.txt for wxgraphic.php, you do have
Code: [Select]
$degree_units = 'F';
which is in ISO-8859-1.

You'll likely need to add to your php.ini in your document root
Code: [Select]
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?
Don - W3DRM - Minden, Nevada --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KRNO2
Davis Wireless VP2, WD 10.37S70,
StartWatch, VirtualVP, VPLive, , Win10 Pro
--- Logitech HD Pro C920 webcam
--- RIPE Atlas Probe - 32849

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 6507
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #11 on: January 14, 2018, 03:51:20 PM »
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
Code: [Select]
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.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3306
    • Carson Valley Weather
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #12 on: January 14, 2018, 04:06:52 PM »
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
Code: [Select]
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.
Don - W3DRM - Minden, Nevada --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KRNO2
Davis Wireless VP2, WD 10.37S70,
StartWatch, VirtualVP, VPLive, , Win10 Pro
--- Logitech HD Pro C920 webcam
--- RIPE Atlas Probe - 32849

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 6507
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #13 on: January 14, 2018, 05:03:54 PM »
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:
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3306
    • Carson Valley Weather
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #14 on: January 14, 2018, 07:09:14 PM »
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:

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.
Don - W3DRM - Minden, Nevada --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KRNO2
Davis Wireless VP2, WD 10.37S70,
StartWatch, VirtualVP, VPLive, , Win10 Pro
--- Logitech HD Pro C920 webcam
--- RIPE Atlas Probe - 32849

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 6507
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #15 on: January 14, 2018, 07:22:28 PM »
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
Code: [Select]
$degree_units = '°F'; and that is where it coming from.

Change the file to be ANSI, and that line back to
Code: [Select]
$degree_units = 'F'; and the problem should be resolved.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3306
    • Carson Valley Weather
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #16 on: January 14, 2018, 07:38:15 PM »
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
Code: [Select]
$degree_units = '°F'; and that is where it coming from.

Change the file to be ANSI, and that line back to
Code: [Select]
$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.
Don - W3DRM - Minden, Nevada --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KRNO2
Davis Wireless VP2, WD 10.37S70,
StartWatch, VirtualVP, VPLive, , Win10 Pro
--- Logitech HD Pro C920 webcam
--- RIPE Atlas Probe - 32849

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 6507
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #17 on: January 14, 2018, 11:10:18 PM »
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
Code: [Select]
$degree_units = chr(176).'F';That is the ISO-8859-1 character code for the degree sign.
« Last Edit: January 14, 2018, 11:12:15 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3306
    • Carson Valley Weather
Re: WXGRAPHIC problem - can't display degree symbol correctly
« Reply #18 on: January 15, 2018, 01:17:01 AM »
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
Code: [Select]
$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...
Don - W3DRM - Minden, Nevada --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KRNO2
Davis Wireless VP2, WD 10.37S70,
StartWatch, VirtualVP, VPLive, , Win10 Pro
--- Logitech HD Pro C920 webcam
--- RIPE Atlas Probe - 32849

 

anything