在JScript中转义转义字符 [英] Escaping escape characters in JScript

查看:105
本文介绍了在JScript中转义转义字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





JScript中,我已经无可救药地与逃避转义字符混淆了!我想做的就是写一个简单的函数:


函数DoubleUpBackSlash(inputString)

{

????? ??

}


将执行以下操作:


<%

var inputString =" D:\Internet \ test2.txt"

Response.Write(DoubleUpBackSlash(inputString));

%>


....在屏幕上打印出以下内容:

D:\\Internet \\test2.txt

任何人都可以为我填写功能中的空白吗?


TIA,


JON

Hi,

I have been getting hopelessly confused with escaping escape characters in
JScript! All I want to do is write a simple funtion:

function DoubleUpBackSlash(inputString)
{
???????
}

which will do the following:

<%
var inputString = "D:\Internet\test2.txt"
Response.Write(DoubleUpBackSlash(inputString));
%>

....printing out the following on the screen:
D:\\Internet\\test2.txt

Can anyone fill in the blanks in the function for me?

TIA,

JON

推荐答案

当你将值传递给你的函数时,你必须已经

有\\\逃过一劫。所以,如果你在字符串值中进行硬编码,那就是你现在正在做的事情,用\s加倍硬编码就已经加倍了。


之后你想用这个值做什么?你把它放在

的客户端javascript函数中吗?如果是这样,必须再次处理逃避现金,但在我们担心之前先告诉我们你在做什么。


Ray在工作


" Jon Maz" <乔**** @ surfeuNOSPAM.de>在消息中写道

新闻:Oo ************** @ tk2msftngp13.phx.gbl ...
By the time you''re passing the value to your function, you have to already
have the \s escaped. So, if you''re hard-coding in the string value, which
you''re currently doing, hard-code it with the \s doubled up already.

What are you trying to do with the value afterwards? Are you putting it in
a client-side javascript function? If so, escaping will have to be handled
again, but tell us what you''re doing first before we worry about that.

Ray at work

"Jon Maz" <jo****@surfeuNOSPAM.de> wrote in message
news:Oo**************@tk2msftngp13.phx.gbl...

在JScript中,我已经无可救药地与逃避转义字符混淆了!我想做的就是写一个简单的函数:

函数DoubleUpBackSlash(inputString)
{
???????
}

将执行以下操作:

<%
var inputString =" D:\Internet \ test2.txt"
Response.Write(DoubleUpBackSlash( inputString));
%>

...在屏幕上打印出以下内容:
D:\\Internet \\ test2.txt

任何人都可以为我填写功能空白吗?

TIA,

JON
Hi,

I have been getting hopelessly confused with escaping escape characters in
JScript! All I want to do is write a simple funtion:

function DoubleUpBackSlash(inputString)
{
???????
}

which will do the following:

<%
var inputString = "D:\Internet\test2.txt"
Response.Write(DoubleUpBackSlash(inputString));
%>

...printing out the following on the screen:
D:\\Internet\\test2.txt

Can anyone fill in the blanks in the function for me?

TIA,

JON



嗨雷,


这就是我所追求的(见我在代码中的评论):


<%

var fso = Server.CreateObject(" Scripting.FileSystemObject");


//无法工作

var wfile = fso.CreateTextFile(" D:\ Inteter \ test2.txt",true);


//工作

var wfile = fso.CreateTextFile(" D:\\ \Internet \\test2.txt",true);


//希望这个工作!

var wfile =

fso.CreateTextFile(DoubleUpBackSlash(" D:\Internet \ test2.txt"),true);


wfile.WriteLine(" This is a test。 ");

wfile.Close();

fso = null;

%>


谢谢,


JON

Hi Ray,

This is what I''m after (see my comments in the code):

<%
var fso = Server.CreateObject("Scripting.FileSystemObject");

//doesn''t work
var wfile = fso.CreateTextFile("D:\Internet\test2.txt", true);

//works
var wfile = fso.CreateTextFile(" D:\\Internet\\test2.txt", true);

//want this to work!
var wfile =
fso.CreateTextFile(DoubleUpBackSlash("D:\Internet\ test2.txt"), true);

wfile.WriteLine("This is a test.");
wfile.Close();
fso = null;
%>

Thanks,

JON


//希望这个工作不会工作JScript的!是否有任何特别的原因,你不想要使用内置的逃生功能

这是必需的?你不能只选择不使用它。如果您分享了

的理由,您可能会对创意解决方案感到惊讶!


雷在工作中


Jon Maz <乔**** @ surfeuNOSPAM.de>在消息中写道

news:Op ************** @ TK2MSFTNGP09.phx.gbl ...
The //want this to work won''t work in jscript! Is there any particular
reason that you don''t want want to use the built-in escape functionality
that is required? You can''t just elect to not use it. If you share the
reason for your desire, you may be surprised by a creative solution!

Ray at work

"Jon Maz" <jo****@surfeuNOSPAM.de> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
Hi Ray,

这就是我所追求的(参见我在代码中的评论):

<%
var fso = Server.CreateObject(" Scripting.FileSystemObject" ;);

//无法工作
var wfile = fso.CreateTextFile(" D:\ Intetert \ test2.txt",true);

//工作
var wfile = fso.CreateTextFile(" D:\\Internet \\test2.txt",true);

//想要这个工作!
var wfile =
fso.CreateTextFile(DoubleUpBackSlash(" D:\Internet \ test2.txt"),true);

wfile.WriteLine (这是一个测试。;
wfile.Close();
fso = null;
%>

谢谢,

JON

Hi Ray,

This is what I''m after (see my comments in the code):

<%
var fso = Server.CreateObject("Scripting.FileSystemObject");

//doesn''t work
var wfile = fso.CreateTextFile("D:\Internet\test2.txt", true);

//works
var wfile = fso.CreateTextFile(" D:\\Internet\\test2.txt", true);

//want this to work!
var wfile =
fso.CreateTextFile(DoubleUpBackSlash("D:\Internet\ test2.txt"), true);

wfile.WriteLine("This is a test.");
wfile.Close();
fso = null;
%>

Thanks,

JON



这篇关于在JScript中转义转义字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆