错误C2026:字符串太大,尾随字符被截断。

时间:2021-10-03 16:48:53

i have a big problem and i dont know how to fix it...

我有一个大问题,我不知道怎么解决它……

I want to decode a very long Base64 encoded string (980.000 Chars) but every time when i to debug it i get this error :

我想解码一个很长的Base64编码字符串(980.000字符),但是每次调试它时,我都会得到这个错误:

Error C2026: string too big, trailing characters truntraced

错误C2026:字符串太大,尾随字符被截断。

I tried this but i can only compare 2 strings throught this method

我试过了,但是我只能通过这个方法比较两根弦

char* toHash1 = "LONG BASE 64 Code";
char* toHash2 = "LONG BASE 64 Code";

if (true) {
  sprintf_s(output, outputSize, "%s", base64_decode(toHash1 =+ toHash2).c_str());
}

Anyone know how i can get it to work?

有人知道我怎么能让它工作吗?

2 个解决方案

#1


2  

As documented here, you can only have about 2048 characters in a string literal when using MSVC. You can get up to 65535 characters by concatenation, but since this is still too short, you cannot use string literals here.

如本文所述,在使用MSVC时,您只能在字符串文字中有大约2048个字符。您可以通过连接获得最多65535个字符,但是由于这仍然太短,您不能在这里使用字符串文字。

One solution would be reading the string from a file into some allocated char buffer. I do not know of any such limits for gcc and clang, so trying to use them instead of MSVC could solve this too.

一种解决方案是将文件中的字符串读入某个分配的char缓冲区。我不知道gcc和clang有任何这样的限制,所以尝试使用它们而不是MSVC也可以解决这个问题。

#2


1  

You can first convert your string to hex and then can include it like this,

你可以先把你的字符串转换成十六进制然后像这样包含它,

char data[] = {0xde,0xad,0xbe,0xef};  //example

And than can use it like a string, append null terminator if needed to.

并可以像使用字符串一样使用它,如果需要的话附加null终止符。

#1


2  

As documented here, you can only have about 2048 characters in a string literal when using MSVC. You can get up to 65535 characters by concatenation, but since this is still too short, you cannot use string literals here.

如本文所述,在使用MSVC时,您只能在字符串文字中有大约2048个字符。您可以通过连接获得最多65535个字符,但是由于这仍然太短,您不能在这里使用字符串文字。

One solution would be reading the string from a file into some allocated char buffer. I do not know of any such limits for gcc and clang, so trying to use them instead of MSVC could solve this too.

一种解决方案是将文件中的字符串读入某个分配的char缓冲区。我不知道gcc和clang有任何这样的限制,所以尝试使用它们而不是MSVC也可以解决这个问题。

#2


1  

You can first convert your string to hex and then can include it like this,

你可以先把你的字符串转换成十六进制然后像这样包含它,

char data[] = {0xde,0xad,0xbe,0xef};  //example

And than can use it like a string, append null terminator if needed to.

并可以像使用字符串一样使用它,如果需要的话附加null终止符。