Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error C2026: string too big, trailing characters truntraced

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 :

Error C2026: string too big, trailing characters truntraced

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?

like image 878
Dieter Avatar asked Mar 16 '23 05:03

Dieter


2 Answers

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.

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.

like image 168
Baum mit Augen Avatar answered Mar 19 '23 05:03

Baum mit Augen


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.

like image 34
Alok Saini Avatar answered Mar 19 '23 03:03

Alok Saini