Jump to content

[SOLVED] Detect/Remove Invisible Characters from String


Recommended Posts

I'm having a weird issue with an invisible character (specifically: '?' mark) appearing in my CSV when my script reads it. I've isolated it down to a simple script so I can share it easily.

Has anyone experienced this issue?

How would I be able to detect/remove invisible characters?

For this specific case FileExist would fail. I could do StringReplace or StringRegExp, but what if it's not a '?' mark or a unc path?

Note: I can see the question mark if I open the CSV in notepad, but not in Excel.

 

Code:

$sPath1 = "\\Server\Share\Folder1‎" ; Copied from Excel 2013
$sPath2 = "\\Server\Share\Folder1" ; Typed out in SciTE


ConsoleWrite(@CRLF)

ConsoleWrite($sPath1 & @TAB & StringLen($sPath1))
ConsoleWrite(@CRLF)

ConsoleWrite($sPath2 & @TAB & StringLen($sPath2))
ConsoleWrite(@CRLF & @CRLF)

Screenshot:

Invisible_Chr.JPG

Script:

Path_Test.au3

 

Any assistance is appreciated, Thanks!

Edited by Surf243
Solved!
Link to comment
Share on other sites

The character in question is a LRM.  https://en.wikipedia.org/wiki/Left-to-right_mark

You could eliminate this specific character with something like this...

$sPath1 = "\\Server\Share\Folder1‎"

$sPath1 = StringReplace($sPath1, ChrW(0x200E), "")

ConsoleWrite($sPath1 & @CRLF)

StringToASCIIArray is helpful for identifying characters you cannot see.

Edited by Tekk
&
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...