Search code examples
phphtmlfirefoxcharacter-encodingurl-encoding

How to force Firefox to save degree symbol using single-byte encoding?


I have this code (degree symbol encoded as HTML):

<a download="text.txt" href="data:text/plain,&deg;">Download degree symbol</a>

What I do

  1. Click the link
  2. Save the file
  3. Open it in TextPad
  4. Problem: I see °, instead of the expected ° (When I do a hex dump I get b0c2)

How do I fix this?

My context is I have a PHP-encoded $string = "&deg;". but for purposes of this example I stripped it down and inserted degree into HTML link directly. I tried using utf8_decode() with same results as above.

I need to open the resulting file in a legacy Windows application that seems to read ASCII only (aka displays ° like above and I need to only have it display the degree symbol).


Solution

  • Courtesy of ... cor-el of Mozilla Support, use this:

    data&colon;text/plain;charset=iso-8859-1,%b0