Invisible Characters

1

Setting up a web example, when I received a string for the html projection from the application, I noticed an inconsistency. I would like help with this.

In one of the moments of the creation of the page I have a treatment of the object to be persisted, and the treatment is this:

   //sobrenome - apenas caracteres
   String s = v.getSobrenome();
   if(s.isEmpty()||!Pattern.matches("[a-zA-Z]+", s))
      v.setSobrenome("!INVALIDO!");

The only problem is that an invalid character (which is between the INVALID O and the exclamation) appeared magically, which does not take up space in the presentation, but is counted by the keyboard cursor. >

When I try to enter the folder of the class to get it from my work and take it home to analyze it, I entered the .java through the browser (Firefox) and I came across this:

   //sobrenome - apenas caracteres
   String s = v.getSobrenome();
   if(s.isEmpty()||!Pattern.matches("[a-zA-Z]+", s))
      v.setSobrenome("!INVALIDO„ƒ„ƒ„ƒ„ƒ„ƒ„ƒ„ƒ„ƒ„ƒ„ƒ„ƒ„ƒ„!ƒ");

I have no place for this character to have "appeared" in the class.

The good thing is that erasing would solve the problem, but I would like to know if someone has already encountered it, already treated and knows its origin.

EDITION

It's starting to get complicated for me. I copied the character and put it in a clean class, and when I tried to save Eclipse it gave me an error, saying it was impossible to save in a character format called "Cp1252".

    
asked by anonymous 26.08.2014 / 13:26

2 answers

0

After some research, I found that the default "CP1252" is the default Windows default, also known as "Windows-1252" or ANSI.

When using the character map to another pattern in my code, the character must have broken or copied some control character, generating this strange ghost character pattern.

CP1252 is also the default for some IDEs, including Eclipse.

    
27.08.2014 / 13:50
0

Yes, this type of error happens frequently and I baptized it as Caracterer Fantasma .

After observations, I concluded that this problem happens when developers exchange code snippets via instant messengers ;

    
26.08.2014 / 13:57