0

I'm trying to do a webBrowser Game.

Here stands a print of the HTML code: Fig 1:

‭669‬

Here stands the code I'm doing to get the value (in this case: 669):

public void getPoducaoHoraria()
{
    string _prodMadeira = chromeDriver.FindElementByXPath("//*[@id='production']/tbody/tr[1]/td[3]").Text;              
    File.WriteAllText("C:\\Users\\Goncalo\\Desktop\\t.txt", _prodMadeira);
    Console.WriteLine("Prod Madeira {0}", _prodMadeira);
}

Output in File: 669
Output in Console: ?669?

Any guess why thoso "?" on console output ?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • What does the variable `_prodMadeira` contain? – awh112 Jun 06 '18 at 17:10
  • @awh112 printing in console it has "?669?". Printing on File it has the the right value i want which is "669" with no "?". – Gonçalo Baptista Jun 06 '18 at 17:13
  • 2
    You may have some Unicode characters in the file that you can't see. In the console, those same characters show up as question marks because [by default, the console support all Unicode characters](https://stackoverflow.com/q/5055659/3224483). You can test this theory by adding some plain ASCII character to the end of the file, putting your cursor just before the 9, then pressing the Delete key twice. If there is an invisible character, then you'll have deleted the 9 and the invisible character, and the other ASCII character will still be there. – Rainbolt Jun 06 '18 at 17:13
  • @Rainbolt it looks like the file only has the 669. I did what you said and it just deleted de 9 and there are no more characters next – Gonçalo Baptista Jun 06 '18 at 17:29
  • Is there anything in the XML that would be causing this issue? Agree with @Rainbolt that it is potentially related to some Unicode characters. What does your source XML look like? – awh112 Jun 06 '18 at 17:56
  • @awh112 sorry, i dont know nothing about XML. – Gonçalo Baptista Jun 07 '18 at 00:22
  • @GonçaloBaptista really you should look at what you are getting back from the browser. Most likely, there are some Unicode characters that are giving you trouble. Specifically you should look at the source from this line: `string _prodMadeira = chromeDriver.FindElementByXPath("//*[@id='production']/tbody/tr[1]/td[3]").Text;` – awh112 Jun 07 '18 at 13:53
  • 1
    Your string contains [Unicode Character 'LEFT-TO-RIGHT OVERRIDE' (U+202D)](http://www.fileformat.info/info/unicode/char/202d/index.htm) and [Unicode Character 'POP DIRECTIONAL FORMATTING' (U+202C)](http://www.fileformat.info/info/unicode/char/202c/index.htm), which are both invisible to the eye, unless the editor reveals them like your console does. – Cœur Jan 08 '19 at 05:40

0 Answers0