我可以在调试模式下停止 Visual Studio URL 解码命令参数吗? [英] Can I stop Visual Studio URL decoding Command Arguments in Debug mode?

查看:37
本文介绍了我可以在调试模式下停止 Visual Studio URL 解码命令参数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将程序设置为回显命令参数并在带有命令参数https%3a%2f%2fas"的 Visual Studio 调试器中运行,它将回显 '

那么你的 Text.txt 的内容就是你的自定义参数的集合.例如:

Text.txt文件第一行是https%3a%2f%2fas,第二行是test,第三行是...

3#那么你可以使用这样的代码:

#include "pch.h"#include #include <字符串>#include <fstream>使用命名空间标准;int main(int argc, char* argv[]){ifstream infile(argv[1]);//打开文件字符串 MyArgus[10];//创建我的替代阿格斯MyArgus[0] = argv[0];//让Myargus的第一个argu=original vs argu[0]如果 (infile.is_open() && infile.good()) {cout<<文件已打开."<<endl;字符串行 = "";整数编号 = 1;while (getline(infile, line)) {MyArgus[num] = 行;数++;}}别的 {cout<<"打开文件失败..";}cout<<MyArgus[0]<

因此您可以在 Text.txt 文件中以这种方式编写参数来设置您的自定义参数,以避免 VS 中的自动 UrlDecode.

希望有帮助:)

If I set my program to echo command arguments and run in Visual Studio debugger with Command Arguments "https%3a%2f%2fas" it will echo 'https://as'

However, if I run from the command line 'myprog.exe https%3a%2f%2fas' then it will echo 'https%3a%2f%2fas'

Why is it handling this differently, and how can I stop it? I have to pass in an argument that is URL encoded and it needs to not be interpreted by Visual Studio first.

Program is C++ and it's Visual Studio 2017 if that is any help.

解决方案

Can I stop Visual Studio URL decoding Command Arguments in Debug mode?

Sorry but I'm afraid the answer is negative. This issue does exist after my test, and as far as I know there is no option in VS now can turn off or control this behavior. For this, I suggest you can Go Help=>Send Feedback=>Report a problem in VS to report this issue to product team.

I have to pass in an argument that is URL encoded and it needs to not be interpreted by Visual Studio first.

And since it works well in command-line. So what you need is to get the UrlEncode format string during the VS debug process in your development. For this you can try:

1.Add some code before where you need the real argument to UrlEncode the argv[1](I think it's https://as). About how to do UrlEncode see this issue.

2.Set the argument in this way, set https% 3a% 2f% 2fasas the argv[1] instead of https%3a%2f%2fas in project properties, then add code to judge if it contains space, if true=>write code to remove the space in it and get a new string you want (https%3a%2f%2fas)

3.Configure your custom Argument file:

1# In vs, right-click the project=>add a Text.txt file into project.

2# Set the only argument in this as Text.txt.

Then the content of your Text.txt is the collection of your custom arguments. For example:

In the line1 of Text.txt file is https%3a%2f%2fas, line2 is test, line3 is...

3# Then you can use code like this:

#include "pch.h"
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main(int argc, char* argv[])
{
    ifstream infile(argv[1]); //open the file

    string MyArgus[10]; //create my alternative argus
    MyArgus[0] = argv[0]; //let the first argu of Myargus=original vs argu[0]
    if (infile.is_open() && infile.good()) {
        cout << "File is open."<<endl;
        string line = "";

        int num = 1;
        while (getline(infile, line)) {
            MyArgus[num] = line;
            num++;
        }
    }
    else {
        cout << "Failed to open file..";
    }

    cout << MyArgus[0]<<endl; // projectName.exe always
    cout << MyArgus[1]<<endl; // https%3a%2f%2fas
    cout << MyArgus[2]<<endl; // test
    return 0;
}

So you can write arguments in this way in Text.txt file to set your custom arguments to avoid the auto UrlDecode in VS.

Hope it helps:)

这篇关于我可以在调试模式下停止 Visual Studio URL 解码命令参数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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