and need a little help along the way. One of the options is to be able to display text entered
from the command line.
Special characters included in the text string required special handling and needed conversion
while the entire command line string was being tested for parameters and a file name or bracketed text string.
The original plan was to handle all special characters by converting them in batch to unused ascii characters,
then converting them back just before storing them in the array for display. The command line entry
includes coded parameters as well as text source, either a file or a text string. I found that I could
do this conversion in batch but could only get as far as a quoted string: "show me ^ and | and & and < and > and ! and %".
Then I could use vbscript in the batch file to remove the quotes and save that in a file. There will be instructional
notes that explain that these characters must be entered with a caret and the percent character doubled.
Now I figure that since I need vbscript, why not just skip most of the conversion and pass back from vbscript
the parsed parameters in one temporary file and source of the text, either a string or a file, in another temporary file,
as well as the error level to indicate what type the text source is.
The good new is everything is working except that pesky " symbol.
Passing a single double-quote to vbscript fails, so I convert it before passing the string. Hopefully you can see
from the code below that passing character for code 157 from batch to vbscript somehow will not convert unless I use code 209.
The code is entered into the batch file with KEDIT for Windows editor by pressing Alt-157. Strangely, when I hextype the line
in my editor, it shows the code to be 165, and an ascii chart shows 165 to be a capital N with a squiggle on top, the same
thing I see when it is echoed.
Thanks for your help.
Code: Select all
<!-- : Begin batch script
@Echo Off
setlocal
Set "str=show me a single double quote: ¥%" & rem ascii code 157
Echo calling script with string that contains character for ascii code 157...
CScript //nologo "%~f0?.wsf" "%str%"
endlocal & exit /b
----- Begin wsf script --->
<job><script language="VBScript">
Option Explicit
Dim text_string
text_string = WScript.Arguments(0)
If InStr(text_string, Chr(157)) > 0 Then text_string = Replace(text_string, Chr(157), """")
WScript.Echo "text_string after attempt to convert chr(157) to a quote: " & text_string
If InStr(text_string, Chr(209)) > 0 Then text_string = Replace(text_string, Chr(209), """")
WScript.Echo "text_string after attempt to convert chr(209) to a quote: " & text_string
WScript.Quit
</script></job>
calling script with string that contains character for ascii code 157...
text_string after attempt to convert chr(157) to a quote: show me a single double quote: Ñ
text_string after attempt to convert chr(209) to a quote: show me a single double quote: "