Jump to content

Strange Characters in my Array


aslani
 Share

Recommended Posts

I believe those are Characters AutoIt cannot recognize, You need to find out what format the File you are getting your info from is Written in and have it translated before you read it with AutoIt.

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

  • Moderators

I believe those are Characters AutoIt cannot recognize, You need to find out what format the File you are getting your info from is Written in and have it translated before you read it with AutoIt.

AutoIt "doesn't" recognize characters?

I believe the only character that causes an issue is Char "0" in ansi mode.

Edit:

Valuater probably hit the nail on the head, but one way to know for sure is to loop through and find the actual Asc value and compare to what is the actual character.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

AutoIt "doesn't" recognize characters?

If you are trying to read a file that has been created using character encoding. such as UTF-8, the result will be small Chunks of information that look normal and small chunks of unrecognizable characters, depending on the file.

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

More info would help... but, just guessing

I had a similar situation and it was due to carrage returns. ie.. @CRLF , @LF, or @CR

you can use StringReplace() to replace the CR with nothing ""

8)

I'm sorry for being vague.

The data came from Excel. Basically, you highlight the area you want from the spreadsheet then my AutoIt Script will clean it up and put in an array as you see in that image. I'm not sure if those characters are extra tabs, but I ran StringReplace() using @TAB, @CR, @CRLF, and @LF but still, those character stays. I even ran StringStripWS() and StringStripCR() and they still remain. :)

Is there a way to find out what that chracters are?

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

  • Moderators

I'm sorry for being vague.

The data came from Excel. Basically, you highlight the area you want from the spreadsheet then my AutoIt Script will clean it up and put in an array as you see in that image. I'm not sure if those characters are extra tabs, but I ran StringReplace() using @TAB, @CR, @CRLF, and @LF but still, those character stays. I even ran StringStripWS() and StringStripCR() and they still remain. :)

Is there a way to find out what that chracters are?

$sMid = ""
For $i = 0 To UBound($avArray) - 1;Your array
    For $ii = 1 To StringLen($avArray[$i]);Separate the array into characters
        ;Run from SciTE
        $sMid = StringMid($avArray[$i], $ii, 1)
        ConsoleWrite("$avArray[" & $i & "] = " & "Char: " & $sMid & " | " & "ASC: " & Asc($sMid) & @CRLF)
    Next
Next

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

$sMid = ""
For $i = 0 To UBound($avArray) - 1;Your array
    For $ii = 1 To StringLen($avArray[$i]);Separate the array into characters
        ;Run from SciTE
        $sMid = StringMid($avArray[$i], $ii, 1)
        ConsoleWrite("$avArray[" & $i & "] = " & "Char: " & $sMid & " | " & "ASC: " & Asc($sMid) & @CRLF)
    Next
Next

and this is what I got.

$avArray[18] = Char: | ASC: 0

So does this mean that the strange characters are Chr(0)?

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

  • Moderators

It's a NULL character as I stated before that AutoIt basically determines as the end of the string. I'm not quite sure if you can do StringReplace($sString, Chr(0), "") or not though.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

It's a NULL character as I stated before that AutoIt basically determines as the end of the string. I'm not quite sure if you can do StringReplace($sString, Chr(0), "") or not though.

The Asc($sMid) command won't do Unicode, so you might try that with AscW($sMid).

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • Moderators

Try this...$New_String=StringReplace(StringReplace($Old_String,@LF,""),@CRLF,"")

That replaces @LF first, which makes the @CRLF a redundant call because there wouldn't be anymore line feeds for the call.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Try this...$New_String=StringReplace(StringReplace($Old_String,@LF,""),@CRLF,"")

This is what I have;

$splitdata = StringSplit(GUICtrlRead($ecorawdata), @TAB)

For $x1 = Ubound($splitdata) - 1 To 1 Step -1
    StringReplace($splitdata[$x1], @TAB, "")
    StringReplace($splitdata[$x1], @CR, "")
    StringReplace($splitdata[$x1], @LF, "")
    StringReplace($splitdata[$x1], @CRLF, "")
    StringStripCR($splitdata[$x1])
    If StringStripWS($splitdata[$x1], 8) = "" Then _ArrayDelete($splitdata, $x1)
Next
$splitdata[0] = Ubound($splitdata) - 1

_ArrayDisplay( $splitdata, "View Array" )

I added those StringReplace() as filters and StringStripWS() should clean them out. But the _ArrayDisplay still shows those UnID's boxes. :/

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

OMG! I GOT IT!!!

Thanks to _ArrayToString(), I managed to remove those strange characters.

Here's what I did.

$splitstring = StringSplit(GUICtrlRead($ecorawdata), @TAB)
_ArrayDelete($splitstring, 0)
$splitdata = StringSplit(StringStripWS(_ArrayToString($splitstring, ","), 8), ",")

For $x1 = Ubound($splitdata) - 1 To 1 Step -1
    If StringStripWS($splitdata[$x1], 8) = "" Then _ArrayDelete($splitdata, $x1)
Next
$splitdata[0] = Ubound($splitdata) - 1

_ArrayDisplay($splitdata, "View Array")

Thank you all for pointing me to the right direction. :)

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

Ok, I found a problem with my previous codes since if I have an element with spaces and commas, the intended spaces and commas were also removed. So to keep the intended spaces and commas, I did this instead,

$splitstring = StringSplit(GUICtrlRead($ecorawdata), @TAB)
_ArrayDelete($splitstring, 0)
$splitdata = StringSplit(StringReplace(_ArrayToString($splitstring, "*"), @CRLF, "*"), "*")
            
For $x1 = Ubound($splitdata) - 1 To 1 Step -1
    If StringStripWS($splitdata[$x1], 8) = "" Then _ArrayDelete($splitdata, $x1)
Next
$splitdata[0] = Ubound($splitdata) - 1
            
_ArrayDisplay($splitdata, "View Array")

:)

Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...