RosettaCodeData/Task/Strip-control-codes-and-extended-characters-from-a-string/VBScript/strip-control-codes-and-extended-characters-from-a-string.vbs
2026-04-30 12:34:36 -04:00

26 lines
678 B
Text
Raw Permalink Blame History

Function StripCtrlCodes(s)
tmp = ""
For i = 1 To Len(s)
n = Asc(Mid(s,i,1))
If (n >= 32 And n <= 126) Or n >=128 Then
tmp = tmp & Mid(s,i,1)
End If
Next
StripCtrlCodes = tmp
End Function
Function StripCtrlCodesExtChrs(s)
tmp = ""
For i = 1 To Len(s)
n = Asc(Mid(s,i,1))
If n >= 32 And n <= 126 Then
tmp = tmp & Mid(s,i,1)
End If
Next
StripCtrlCodesExtChrs = tmp
End Function
WScript.StdOut.Write "ab<61>cd<63>ef<65>gh<67>€" & " = " & StripCtrlCodes("ab<61>cd<63>ef<65>gh<67>€")
WScript.StdOut.WriteLine
WScript.StdOut.Write "ab<61>cd<63>ef<65>gh<67>ij†klð€" & " = " & StripCtrlCodesExtChrs("ab<61>cd<63>ef<65>gh<67>ij†klð€")
WScript.StdOut.WriteLine