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

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!

Related

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

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?

P4VS code lens integration shows all file-level changes for each function

(I've looked far and wide but I can't even find anyone having the same problem, not to mention a fix or anything. Closest is this thread which just announces the feature...)
The way it currently works for me, the VS2019 code lens integration of P4VS (for C++ at least) is almost completely pointless. Each function has an indicator added, but the information in each is identical - namely the change history of the entire file:
According to this Microsoft article, I would expect to either get function-level change information that pertains only to that function or a single change summary of the file at the bottom of the editor. But instead I get the worst combination of both.
I'm mainly surprised that I can't find anyone else talking about this, so I assume something is misconfigured on my part. Can't find anything in the configuration options though...
Is this just a bad implementation by Perforce or is something wrong on my end?
I have just found out that it can be turned off by Visual Studio options.
How to turn off CodeLens-References
Text Editor > All Languagues > CodeLens

Is there a way to make a property for a vcxproj in the Property Pages not be bolded using Visual Studio 2013?

I know that when a property appears bold in Property Pages it indicates that it has been modified.
https://msdn.microsoft.com/en-us/library/675f1588.aspx
I have an API that we ship samples with, and I want all of the settings across all of them to be consistent and the same.
Unfortunately, some sample vcxprojs appear to have the right setting and are not bolded, while others somehow had a wrong setting and after changing it to the right one, it's obviously still bold.
I want all of the samples Property Pages to be consistent across all of the samples, even the bolding of text. I realize this is really just an OCD cosmetic type of an issue, and there is no technical problem behind it.
The .vcxproj file is just an XML file. I'm assuming that bold means that there is a setting specified in the file, even if it's the default.
So: edit the file in a normal text editor. Remove the setting, so that it uses the default value, and so that it no longer appears in bold in Visual Studio.

Enforcing coding styles in Visual Studio and VIM

I work with a medium sized team of developers, with half being Linux developers using VIM on Ubuntu and MacVIM on OSX, and the other half being Windows developers using Visual Studio 2010 or later.
A fair bit of time has been wasted in the past when handling things like SVN operations failing due to mixed line endings, or changes to code reviews due to a mix of hard-tabs versus spaces-as-tabs (and sometimes of varying lengths, ie: 4 spaces vs 2 spaces vs 8 spaces, etc), and I would like to put an end to it.
The plan is to adapt a common coding style we've designed, which is almost identical to the Linux Kernel coding style. For all developers, we could require them to run their code through the checkpatch.pl script used by Linux kernel devs, but our code includes C, C++, and C#, so we would need to generalize the rule checker script beyond just ANSI C.
Is there a generic way to implement a rule set for VIM, and another for Visual studio? We'd like to generate a script that checks entire files, which could be hooked into our version control system so that it's run on code before commits complete, and perhaps as a run-time script to enforce the style as coders type?
Thank you.
EditorConfig seems to do exactly what you want in Vim, Visual Studio, and a lot of other editors and IDEs.
The run-time "script" is the best first-line of defense. In this case, it will be various Vim and Visual Studio settings to help enforce your code style. That alone will catch quite a few problems. Keep in mind, this won't catch everything, but will encourage the coding style you want.
I've worked across Linux & Visual Studio in a team before (and sometimes by myself). The whole Tabs/Spaces issue drove me nuts as there would be wholesale groups of lines that were either shifted WAY over or not enough. To solve this, I ended up using these three settings in Vim (also set similar values in Visual Studio), thus catching one class of issues at the root.
Vim
set expandtab
set shiftwidth=4 " Mainly for if/for/while/general {} block indentation. 4 spaces.
set softtabstop=-1 " Allows us to use the Tab key and have it act like shiftwidth.
Visual Studio
Insert spaces when Tab key is pressed.
Shift 4 spaces on indent inside code block
They key is getting rid of the Tab characters, or at least having both systems use the SAME SETTINGS (i.e. both using Tab with the same values or SPACEs substituting as Tabs)
Something to watch out for:
Someone copying a file from one Operating System to a different one and then checking the file into SVN on that machine. SVN will blindly commit, say, a DOS line-ending file from a UNIX system. You want to checkout/commit files on the same system only. Otherwise, checking out/editing/committing files all on the same OS should present no issues, as SVN can convert the line endings upon checkout. You can "fix" this by loading a file into Vim and then converting the line-endings to the particular OS you want by typing ":set fileformat=dos" (if you want to change to Windows-style), ":set fileformat=unix" (for unix style), or finally ":set fileformat=mac" for Mac.
As far as the code style goes, as you probably already know, both Vim and Visual Studio offer lots of flexibility there. While I cannot give you the specific settings for Vim, the options to look at are
autoindent
cindent
cinoptions (implied from cindent)
cinkeys (implied from cindent)
comments (default is probably fine, but here for thoroughness)
So, you will want
set autoindent
and cindent should be automatically set when editing a C or C++ file. The defaults for cinoptions and cinkeys are ok for me, but I have tweaked them in the past when working with a different group.
Don't forget about using the '=' command over a selected range of lines to reformat the code! This can be very handy!
I shy away from the completely automatic SVN backend method because it may take longer than you expect to get it right, and when it screws up, it will probably take more time out of your day than you expect as well. After all, you really just want to be productive, right?.
Discipline up front is key!

How can you "global replace" in Crystal without visual studio?

I had to replace a DB table with embedded SQL in Crystal.
Now I find myself completely amazed that (apparently) I have to open thirty or more formulas one at a time and replace the table name with "Command"
If I select "All formulas" in the replace widget, all the replace controls are disabled.
This is so stupid that I figure I am missing something.
I am working the Crystal files directly in the Crystal IDE. Not able to fire up a C# or VB program to do it for me. I did try a couple of times in the past to edit things in Crystal files with regexp/perl/editors and similar, but that failed due to the Crystal file format.
(S.O. says my question "appears subjective and is likely to be closed." Huh?)
Transitioning from linked tables (Database 'expert') to a command (or the other direction) has always been painful (I've been using the product since v4)--CR doesn't have a good (or even mediocre) way to do this. You should be able to map your command to a single table, but you'll lose field (from the canvas) during the process (because CR will remove unmapped fields). Best practice is to always use a command or to wrap each table.field element in a formula field.
With earlier version of the product, I might have suggested using the SDK to make the change. However, this level of control has been shifted to BusinessObjects' RAS SDK.
If you are interested, have a look at my RptToXml project or its C# replacement.