Jump to content

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.

Link to comment
Share on other sites

Look at StringReplace and Chr.

Alzo

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

Link to comment
Share on other sites

  • Moderators

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.

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

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

Link to comment
Share on other sites

  • 14 years later...

You noticed that this thread is 14 years old :/

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...