User forums > Help

Seemingly empty .cpp file?

(1/1)

Firana:
I have a ~2kb .cpp file I created in CodeBlocks on a different computer (that I don't have access to anymore), with some code that compiles and runs no problem. However, whenever I try to open it in CodeBlocks on my own computer, it looks as-if it's completely empty. It's not - it still compiles and runs on this device (though the result is somewhat different from what it should be), and I can still see the code when I open it with Notepad++.

I suspect the issue might be related to language encoding, as that code contains quite a few characters specific to central/eastern European languages (that part is non-negotiable as it is a part of my assignment to deal with various encodings, I cannot simply remove them). Whenever I open the file on my own computer in Notepad++, instead of the specific characters I put in, I see scrambled garbage (it was fine on the other computer).

I tried opening the file in Notepad++, changing its encoding, and copying the code into a new empty CodeBlocks file, but then I get this error:
error: narrowing conversion of '50309' from 'int' to 'char' inside { } [-Wnarrowing]|

Which I'd guess could be due to the character being interpreted as encoded in UTF-8 or something...? I don't know what's happening.

stahta01:
Do you save it as unicode? If not try that.
Edit: Note copy and pasting is not as good as file save as with new encoding and new filename.

If yes, then post the build log and the first line of code with the error.
NOTE: Posting code is often against the rules but, I think none will complain about one line of code.

Tim S.

nenin:

--- Quote from: stahta01 on January 19, 2024, 08:04:58 pm ---Do you save it as unicode? If not try that.

--- End quote ---
I can confirm issue. It is rare (I faced it 2-3 times last 2 years). I suppose it is corrupted unicode  issue. I solved it by copy-paste code from notepad++ to C::B. I suspect that these problematic files  were generated by some early nightly builds of C::B64.

Grit Clef:
I'd met this problem in the past,  too. It maybe isn't completely  related to CodeBlocks, in my case. Often it's occurred when you switch between different editors. I had solved them in the similar way to nenin's, and by chance.

Navigation

[0] Message Index

Go to full version