Why can't I change the code page in Visual Studio? - c++

New here, so I'll try to explain my problem as best as I can.
I tried coding a program in Visual Studio C++ that reads Japanese letters from a text file and displays them. The debug console gave me weird hieroglyphic-looking symbols.
I did some research and can deduce that that's because I was using an ASCII codepage which can read and display only the most common letters, like the Western alphabet. It was something along those lines.
I changed the system locale in Control Panel > Region > Administrative > System Locale to Japanese. After this, the fonts changed and some of the text in the debug console in Visual Studio displayed differently than before. However, it still displayed errors, so I gave up and tried changing it back to the default settings, but I'm having trouble.
My main goal is to try to revert everything back. In the debug console properties, it shows that the codepage I'm using is still Japanese, even after many attempts to fix it and reset the settings to default. I want the fonts to go back to "Consolas", but that option isn't available anymore. I even tried looking in the Registry after looking up answers, but everything was in its rightful place.
Can anyone give me some assistance?

Related

Visual Studio 2019 - open files with specific encoding (e.g. 437)

I got some legacy projects, with a source code encoding of IBM437/CP437. They need to be encoded that way at the moment, so please refrain from recommending a switch to utf-8.
So far I have unfortunately not found exactly what I need.
I experimented a lot and searched for several hours, yet my best workaround is the following:
While having the project opened in solution explorer, right click -> open with -> C++ Source Code Editor (with encoding).
In this huge dropdown I can choose the file encoding I need OEM United States - Codepage 437.
This is exactly what I need, but preferably automatic / persistent.
In the "Open With" window, the "C++ Source Code Editor (with encoding)" can also be set as default. This is a step in the right direction already, yet not at the right destination! With this setting, every time I open one of the files, I still need to use the dropdown and select the correct codepage every single time!
If anyone have anidea how to get this to work automatically, this would be great!
Most of the search results are about saving files in specific codepages, rather than opening them.
I tried playing around with .EditorConfig, yet it seems to support only like 5 codepages.
Also looked into the VS extensions and tried some. The FileEncoding extension looked promising, but it seems to just use .EditorConfig below the surface, since it's limited to the same few codepages.
Side note: I would even be perfectly fine with my Visual Studio opening all files in this codepage (for editor). So if someone knows a hack in that direction, it would be good too.
For example if I change the whole system codepage via registry keys:
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\OEMCP=437 (this is usually default for Western Europe)
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP=437 (ANSII Code Page)
It might work too, yet it's super dirty and system wide. Therefore I would rather live with the manual selection every time...
Also I could live with a shortcut, switching to the desired codepage. I used this approad in notepad++ for quite some time and got used to it. There I had a shortcut, e.g. ALT+X, switching to OEM US.
To summarize this up:
My perfect solution would be similar to the Open With -> C++ Source Code Editor (with encoding) workaround, but without having to select the codepage every single time!

Why isn't my terminal running my updated C++ code?

I am a new programmer and I am trying to use the terminal on my Mac to compile and run the C++ code I write using the Sublime text editor.
I am able to get my code to run using the terminal, however, whenever I make changes to my code on sublime and then re-compile it on my terminal, my terminal doesn't recognize my changes and keeps on running my original code.
Does anyone know what might be happening?
Thank you so much!
I can think of two possibilities that spring immediately to mind. If you're changing your code in the editor, and that's not being reflected in the compilation, then it's likely to be one of the following. Either:
you're not saving the file in the location you think you are; or
you're not saving the file at all.
The easiest way to tell if one of these is the case is to introduce an error into your code(a), like:
int my hovercraft = full of eels;
and make sure the compiler complains about it.
If you're not saving it at all, do so. If you're saving it in the wrong place, you can usually find out where just by doing a Save As and seeing where the default location is.
If you're annoyed that you have to save, and that computers should just "work"(b), Sublime Text has an auto-save feature that may come in handy, courtesy of one Lucy Bain. Instructions (paraphrased) are duplicated here in case that site ever disappears:
Open Sublime
Find Settings and edit the user window (under Sublime Text 2 > Preferences for Mac, just Preferences for Windows).
Add the line "save_on_focus_lost": true.
Save and close the file.
At that point, whenever you click away from a particular file, it should save it.
(a) Some developers seem to have little trouble doing this without even trying :-)
(b) A not unreasonable expectation for a Mac user :-)

Visual Studio 2017 (15.3.1) keeps hanging/freezing

I have recently installed Visual Studio 15.3.1 Community Edition (although I suspect this affects all editions). When doing actions such as
closing SQL .sql file tabs
copying or renaming files
other actions which I can't pinpoint
Visual Studio will freeze or hang for a few seconds or permanantly. It sometimes displays "(Not Responding)" in the title bar, but not always. This is getting really frustrating.
It seems like the Visual Studio feedback system is at fault. Turning it off solved my problem.
Open Visual Studio
Navigate to Help > Privacy > Privacy Settings
Select the "No, I would not like to participate" radio button and click OK
Hopefully whatever bug is causing this issue will be fixed soon and I'll happily participate in the feedback program again!
See this issue posted a lot on the MS forums.
I struggled with it for a while. When editing XAML files, it would always freeze and hang.
Tried many solutions that didn't fixed it. Then, I found the solution that did fix it for me.
I made two changes at the same time, so I can't say for sure which one solved it, but I can guess.
First change, which probably isn't the fix, is that I added the registry keys from this page. They were missing on my system. Page has a lot of detail, but having those keys set properly can't hurt. I noticed in Process Monitor that it was missing on the following regkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\Setup\CachePath
Second change I made, the one I'm guessing solved the issue, was deleting the 17k+ ".TRN" files inside the following directory:
%LocalAppData%\Microsoft\VSApplicationInsights\
On my computer they were in something like the following:
C:\Users\Michael\AppData\Local\Microsoft\VSApplicationInsights\vstelXXX_SOMEGUID
Going back to check now, and after three-or-so hours of work there's another 475 files in that folder. It's producing about four or five .TRN files a minute, all with encrypted data inside. Not going to speculate as to the purpose of it, but I doubt it's anything good or useful. Deleted all those, and the XAML editor in VS now works fine, or at least as well as it ever did. No more 30+ second hangs on a modern twentysome core workstation.
In the recent update of VS 2022, the program suddenly starts freezing (randomly) and the fix for me was to turn off inline hints (the thing that pops up when you double click Ctrl key).
I'm using VS for C++ so I turned it off for C++ specifically
Go to the Tools menu tab -> Options

Commit C++ Intellisense suggestion with space bar in VS 2013

I have recently been exploring C++ some after using C# exclusively for quite awhile. I'm using Visual Studio 2013 and the one thing that is bugging me to death is the inability to commit an Intellisense suggestion by pressing the space bar. I have tried to edit the commit character list in Options -> Text Editor -> C/C++ -> Advanced to accept the space bar but so far I've had no luck. Coming from C# this is very aggravating. Does anybody know if it's possible to make such a change? I know I can use Tab or Enter, but in my opinion using Space is far more fluid.
Any information would be greatly appreciated.
UPDATE: Space seems to commit some suggestions but not others. if I type "std::stri", it commits "std::string". Unfortunately, Intellisense won't commit anything created by me or even common keywords. It just adds a space after what I already typed.
Further to my comment on your question, I have installed the trial version of Visual Studio 2013 (Ultimate), and can confirm that space bar does work to complete IntelliSense suggestions. Combining all comments, it would appear that it works in the following versions:
VS 2010
VS 2012
VS 2013
Here is a screenshot of my IntelliSense settings located at Tools > Options > Text Editor > C/C++ > Advanced:
As a last resort you may want to try changing all your settings back to default, as suggested in this answer:
Tools > Import and Export Settings > Reset all settings
UPDATE: After reading JoshC's comments, I have experimented a bit more and I get the problem too. It appears to be related to whether or not the item you are trying to autocomplete is a member of a type or namespace. If it is (e.g. std::string) then space will work. If it is not (e.g. void) then it will not work (but for some reason, tab will work). As per this link, you can manually invoke the "List Members feature" by pressing CTRL+J in which case on a blank line it will include items which are in the global namespace - however this is clearly not a practical solution.
I have no idea why it discriminates between space and tab in this way. If anyone is aware of a workaround please let me know and I will edit this answer again.
The following would seem to imply that there is no solution for C++:
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2656132-support-committed-by-pressing-the-space-bar-in-c
When using Visual Studios 2012 for coding in C++, how do you autocomplete code selected in IntelliSense? (see comments)

Visual Studio 2010 Improperly underlining code/comments with red error line when there is no error

I am working on a rather large project, and I am having strange problems with the IDE in terms of error checking and somewhat with IntelliSense.
Usually if I were to type something boneheaded, like "int a = "aa";", it would underline "aa" in red. However I am seeing VS do this to random parts of my code when I make insignificant changes.
For example:
/*
Some comment here, just going to stretch it out for my example..
*/
int proto1();
int proto2();
If I make changes to other parts of the project, sometimes random functions will get underlined, and even part of a comment. Like just 30 minutes ago it underlined the equivalent of half of that comment beginning in the middle of the word "comment", also it underlined all of int proto1(); and part of int proto2();
I would post screenshots but I am bound by contract not to disclose any work, and I can't easily replicate it in smaller projects.
I don't understand why it does this. When I compile the project, any fake errors and underlining it did goes away and it compiles fine. The point though, is there are no errors. It's making up random errors and underlining random lines/words/half words. I would also like to note that there seems to be a large delay in loading new intellisense information, almost by 2-3 minutes or longer.
I'll try and reproduce it in an unrelated project and post here if I can. However, any help would be appreciated.
Thanks!
*Edit: Forgot to note that hitting the space key several times will on occasion correct the errors however this isn't reliable and does not always work.
Intellisense sometimes can really get stuck with complicated code. I guess until VS2012 release comes out, there's nothing we can do.
There's however one trick that I'm using if this happens - switch your build configuration Debug -> Release and then back again. You don't have to wait, you can just click two times on this drop-down box. It should refresh IS cache and make red error underlines dissappear.
Intellisense is often off, but make sure you have latest updates installed.
I just installed sp1 yesterday and lot of Intellisense issues went way.
I see this is a stale question but some may find this helpful.
I just had this same issue. I tried many of the solutions outlined here and elsewhere. I finally tried running Visual Studio as another user (Shift Right Click Run As Different User) and the issue did not present. I then logged into my computer as another user and deleted the profile of the user I was having the issue with.
If your profile is important to you or there is information within it that is important I highly recommend backing up relevant information first. If you don't understand what information you profile contains make sure you do prior to deleting it.
1) Log in as different user (with admin privileges) than you want to delete
2) Open Properties for Computer
3) Advanced system settings (on the left side)
4) Settings for User Profiles (in the middle)
5) Select the profile you want to delete and click the delete button
6) Reboot
Credit to:
https://superuser.com/questions/63017/how-do-i-delete-a-user-profile-on-a-windows-7-machine-that-is-part-of-a-domain
I had the same issue, and in my case it was mostly related to library functions and types defined in libraries. This one fixed it for me:
Open command line parameters. You can use following to reach there:
Project > ProjectName Properties > Configuration Properties > Linker > Command Line
In the Additional Options box at the bottom add
/I "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"
You will of course need the correct path where Visual Studio is installed.
Bingo! I hope it works for you too. :)