Jump to content
Roderug

Remove non-ASCII from string

Recommended Posts

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.

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.

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

You noticed that this thread is 14 years old :/


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...