Surf243

[SOLVED] Detect/Remove Invisible Characters from String

3 posts in this topic

#1 ·  Posted (edited)

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!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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
&
1 person likes this

Share this post


Link to post
Share on other sites

#3 ·  Posted

Awesome!

Thank you!

Share this post


Link to post
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

  • Similar Content

    • ur
      Date difference is not working
      By ur
      I am assigning the current time stamp to a variable $strtTime and holding the execution for 5 seconds with Sleep and calculating the current time stamp.
      Ideally, the _DateDiff should give 5 seconds as output as i gave the parameter as s.But it is giving zero 0.
      Any suggestions....!
      Global $startTime = _Date_Time_GetLocalTime() $startTime = _Date_Time_SystemTimeToDateTimeStr($startTime) Sleep(5000)     $tCur = _Date_Time_GetLocalTime()     $tCur = _Date_Time_SystemTimeToDateTimeStr($tCur) $iDateCalc = _DateDiff('s', $startTime, $tCur)     MsgBox(0,"$iDateCalc",$iDateCalc)     FileWrite ($QTPfile,CHr(34) & $tCur & CHr(34) & Chr(44) & """" & $iDateCalc & """,")  
    • TheDcoder
      Boolens: Does not work as expected in case of strings
      By TheDcoder
      Hello, I am in a little confusion with Boolens , Here is my code:
      ConsoleWrite(("Something" = "Samething") & @CRLF) ; False ConsoleWrite((Not "Something" = "Samething") & @CRLF) ; True ConsoleWrite((Not False) & @CRLF) ; True I have commented the results which I expected, but the expression in the 2nd line is not working as expected , Can anyone explain to me?
      SciTE Output:
      Thanks in Advance, TD
    • ioripalm
      How to format and print out a lot of strings
      By ioripalm
      How a lot of string formatted output to a printer?
      E.g:
      1) The first line of Arial font and size 20 and Bold
      2) The second line to the fourth line of  Tahoma font and size 14
      3) Insert two blank lines every 5 row
      4) Every 64 rows to add a page break (chr(12) ) and add headers and footers
      5) Finally, the formatted string output to a printer(Dot matrix printer)
      How to do that?The printer supports ESC / P,  ESC / P2,  ESC / PK, ESC / PK2,  Epson Standard Code for Printer.
      Thank you very much!!!
       
    • HelpfulToasty
      Writing a Function, inside a Function?
      By HelpfulToasty
      So, I'm trying to make this autoit script, and there's a function and stuff, but I can't write a function, inside a function! It's just not working.
      Like;
      Func Function_A($para1) Local $thing = 1 Func Function_B() ;Stuff here EndFunc If Function_B($thing) Then ;Stuff Else ;Stuff EndIf EndFunc ; Something like that. I'm either doing it wrong, or I can't do it in autoit.
      Anyway, help me please!
    • TheDcoder
      Problem with a string (Very simple problem)
      By TheDcoder
      Hello,
      I can understand why this:
      MsgBox(0, "", @AppDataDir & '\.minecraft\saves' & $myVar & '.ext') Is returning C:UsersDamonAppDataRoaming.minecraftsavesC:UsersDamonAppDataRoaming.minecraftsavesvariable here.ext
      $myVar = "variable here"
      I want C:UsersDamonAppDataRoaming.minecraftsavesvariable here.ext