草庐IT

long_string

全部标签

c++ - C 字符串和 std::string 之间的转换导致平台特定方式出现乱码

我今天正在处理一个特定于平台的错误,在这个错误中,在Windows机器上某个字符串会非常乱码,但在Mac上则不会。该错误与在std::string和constchar*之间进行显式和隐式转换的几行有关。基本上,我有一个带有签名的函数voidfoo(conststd::string&id);foo在某些时候打印字符串。在Windows上,如果像下面这样调用,它会打印带有不同程度损坏的id字符串(混淆前几个字符或整个字符串)std::stringmystring=bar();constchar*id=mystring.c_str();foo(id);//passtheCstylestrin

c++ - 涉及 `std::string` 的编译导致 Windows 错误状态

最小的例子:#include#includeintmain(int/*argc*/,char*/*argv*/[]){HANDLEhandle=GetStdHandle(STD_OUTPUT_HANDLE);//Behaviorthesame,withorwithout.DWORDerr=GetLastError();std::stringstr;return(int)err;//returns127ifflineaboveuncommented,0iffcommented}此程序返回127,对应于ERROR_PROC_NOT_FOUND(“找不到指定的过程。”)。请注意,err是在s

string - 为什么 CALL SET 在 CMD Windows 和 .CMD 文件中的工作方式不同?

我正在尝试以编程方式使用WindowsCMDSET字符串操作版本。SET的两个版本是...SETNew_String=%String:Old_Text=New_Text%在变量String中将Old_Text替换为New_Text,并在变量New_String中返回结果。SETNew_String=%String:~Number_Of_Chars_To_Skip,Number_Of_Chars_To_Keep%在变量String中,在跳过Number_Of_Chars_To_Skip之后提取Number_Of_Chars_To_Keep,并在变量New_String中返回结果Old_T

string - 无法将字符串从 vba 传递到 Windows dll

我有64位Windows10和MSOffice64位。我正在尝试让PowerPoint的VBA在自写的64位WindowsDLL中加载和执行函数。问题是我无法将字符串从VBA传递到WindowsDLL。各种网站上有很多讨论,但我还没有找到一个有效的。我尝试了两种方法但没有成功。如果我使用调用DLL的C++应用程序,我没有问题。方法一:动态链接库:extern"C"{__declspec(dllexport)longjaadd(longa,longb,LPCWSTRstrg){MessageBoxW(NULL,strg,L"DLL",MB_OK);returna+b;}}在VBA中:Pr

c# - 我需要帮助在 C# 中使用 <string, char> 格式的字典

这篇文章是关于我在C#(VisualStudio2017中的Windows窗体应用程序,.NETFramework)中遇到的关于使用“字符串,字符”格式的字典的困难。这是我的:首先-一种格式的字典Dictionarybintoascii=newDictionary(){{"01000001",'A'},{"01000010",'B'},//..................{"01111010",'z'},{"00100000",''},};以及实际的转换代码:AsciiOutput.Text="";Stringbinninput=Input.Text;for(inti=0;i0)A

C++:将 __int64 转换为 unsigned long

我想在Windows和Linux中使用以下函数,但我不确定如何将__int64转换为unsignedlong。像我一样投值安全吗?getTimeInMilliseconds(){#ifdef_WIN32staticconst__int64magic=116444736000000000;//1970/1/1SYSTEMTIMEst;GetSystemTime(&st);FILETIMEft;SystemTimeToFileTime(&st,&ft);//in100-nanosecs...__int64t;memcpy(&t,&ft,sizeoft);return(unsignedlon

string - 如何使用CMD拆分字符串

我有一个小问题。我想用cmd分割字符串。示例:emre;bahadir;131213034;computer我想var1=emrevar2=bahadirvar3=131213034var4=computer请帮帮我!:) 最佳答案 只需使用常规的FOR循环@EchoOFFSet"str=emre;bahadir;131213034;computer"For%%_In(%str%)DO(echo%%_)Pause&Exit/B0 关于string-如何使用CMD拆分字符串,我们在Stac

c++ - 将 basic_string<char16_t> 传递给只接受 wchar_t * 和 char * 的方法

当您只能获取存储在char16_t的basic_string中的值时,如何使用仅接受char*和wchar_t*的方法?例如在cstdio中删除。cstdio中的remove函数只接受char*和wchar_t*。不能将char16_t转换为wstring:link.Char无法处理所有UTF-16字符 最佳答案 您需要对卡在std::basic_string中的UTF-16进行转码到采用std::string的任何函数所使用的正确编码或charconst*作为论据。同样,您需要在定位wchar_t时更改编码基于序列。当然,随着人们

c++ - 遍历 std::vector 以从 std::string 数组中查找匹配项,更简单的方法?

我循环遍历std::vector和std::string数组以从vector中找到匹配项。例子:#include#include#includeintmain(){std::coutmyVector;myVector.push_back("Word");myVector.push_back("Word2");myVector.push_back("Word4");myVector.push_back("Word6");myVector.push_back("Word7");std::stringmyStringArr[]={"Word","Word1","Word2","Word3",

windows - 批处理文件中的 git archive "The input line is too long. "错误

我设法从各种来源修改了我发现的脚本,以创建在2个变更集之间添加或更改的文件的存档。批处理脚本如下:setlocalenabledelayedexpansionsetoutput=for/f"delims="%%ain('gitdiff--name-only%1%2')do(setoutput=!output!"%%a")gitarchive-oexport.zipHEAD%output%endlocal这在今天之前一直很好用,突然间我收到了以下错误:Theinputlineistoolong.Thesyntaxofthecommandisincorrect.我已经确认造成这种情况的原因