Remove no ascii codes

I am using an esp8266 as my main processor (no arduino hooked up to tx and rx) and I can read in the wifi name from the EEprom, but when I display it as the value=" wifivariablename" I end up getting a bunch of ��� where there are not characters. When I check the string length of the wifi name it comes up as 32 characters, even though it's only 7 characters, so it's counting the � as characters. the eeprom shows them as 0's when I print them in the serial window.

How do I eliminate the extra spaces, and I guess change any spaces to the space charcter, not �

s += "</label><input name='ssid' length=32 value=""";
      s += esid;
      s += """> ";

the html code that is displayed looks like this, and interestingly when I cut from the browser and paste to this message all the extra spaces are gone, so I've simulated them:

<form method='get' action='a'><label>SSID:chipdip            </label><input name='ssid' length=32 value=chipdip              >

Your error is in line 33. That my best guess since you didn't bother to post your code.

I was thinking it was on line 33.

Here's the way I suck up the wifi ssid name. It's basically cut and paste and works fine. I can write to it and read it back and it works great.

Here's how I read it.

String esid;
EEPROM.begin(512);
for (int i = 0; i < 32; ++i)
 {
   esid += char(EEPROM.read(i));
 }
 Serial.print("SSID: ");
 Serial.println(esid);
 Serial.print(esid.length());

Here's how I write it.

 String req;    
Serial.println("clearing eeprom");
      for (int i = 0; i < 96; ++i) {
        EEPROM.write(i, 0);
      }
      String qsid;
      qsid = req.substring(8, req.indexOf('&'));
      Serial.println(qsid);
      Serial.println("")

Serial.println("writing eeprom ssid:");
      for (int i = 0; i < qsid.length(); ++i)
      {
        EEPROM.write(i, qsid[i]);
        Serial.print("Wrote: ");
        Serial.println(qsid[i]);
      }

It writes it as 0's and reads as 0's, but when I test the string length it comes up as 32 bytes, which is the correct size for the ssid field, but my network name is only 7 characters.

If I search google on the character I found a site that tells me all about it.

Interestingly enough when I copied and pasted the web address to this page the � symbol was replaced by %EF%BF%BD

here's what I found. It's a table and it's much easier to see on the linked page.

1 unique codes for 1 characters:
Hex Dec
Native Symbola [1] Code UTF-8 UTF-16 LE Name Cat Block
� � FFFD EF BF BD FD FF REPLACEMENT CHARACTER So Specials
1 Unicode block:
Name Range Chart
Specials FFF0-FFFF PDF

I think it has something to do with utf 8, but not sure.

I solved it.

for (int i = 0; i < 32; ++i)
  if (int(EEPROM.read(i)) > 31) 
  {
    esid += char(EEPROM.read(i));
  }

I test to see if the acsii character is less then 31. If so then skip it because it's a control character.

32 is a space and is allowed as part of the ssid.

I write 0's to the first 96 bytes to make sure they're clean, and so when I read in the first 32 bytes I get 0's which the char(EEPROM.read(i)) function converts 0. 0 is a control byte so the processor ignores it but when I send that string to a web page it shows the 0's as �.

Interesting and a bit mind numbing.

I think that was on line 33! haha!