Sign in to follow this  
Followers 0
Roderug

Remove non-ASCII from string

5 posts in this topic

I copy text to the clipboard and want to skip SOME defined non-printing characters before sending it the the next application. Ideally I would like to define the characters to be skipped in a (hard coded) list, but alternatively it would do do if I could save only the ASCII characters.

Share this post


Link to post
Share on other sites



Look at StringReplace and Chr.

Alzo


Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

I copy text to the clipboard and want to skip SOME defined non-printing characters before sending it the the next application. Ideally I would like to define the characters to be skipped in a (hard coded) list, but alternatively it would do do if I could save only the ASCII characters.

Well do you have a "test" string of what you don't want, and what you would like?

If IsString('Text') ThenoÝ÷ ÙëÉ"Ú½¨.xz0z÷«jëh×6For $i = 1 To StringLen($String)
    $Char = StringMid($String, $i, 1)
    If StringIsASCII($Char) Then 
        ;Something
     EndIf
Next
Might be something to work with.

[center]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.[/center]

Share this post


Link to post
Share on other sites

HI,

maybe this func helps out:

;===============================================================================
;
; Function Name:   _StringRemove
; Description::    Removes certain characters or phrases from a string
; Parameter(s):    $s_string - String
;                   $s_remove - Characters to be removed (separated by $s_delim)
;                   $s_delim[optional] (delimiter '|' by default)
; Requirement(s):  None
; Return Value(s): On Success - String with removed characters
;                   On Failure - 0
; Author(s):       RazerM
; Notes:           Only useful when removing lots of characters
; Example:           MsgBox(0,0,_StringRemove("102.3040506.0700...80900.", "0|."))
;
;===============================================================================
;

Dim $s = "Thorsten Meger"

MsgBox(0,"",_StringRemove($s,"e,o,r"))

Func _StringRemove($s_string, $s_remove, $s_delim = ",")
    $s_remove = StringSplit($s_remove, $s_delim)
    If @error Then Return 0
    For $i = 1 To $s_remove[0]
        $s_string = StringReplace($s_string, $s_remove[$i], "")
        If @error Then Return 0
    Next
    Return $s_string
EndFunc

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Tanks for your responses. My source are clipboard copies from Microsoft Word and they contain "temporary hyphens". (Don't know the correct English grammar. My office suite is Dutch;).

But all your input has enabled me to both solve my problem AND gaining insight in this scripting language.

Regards,

Roderug

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
Sign in to follow this  
Followers 0