Fix issue With VS Code: yellow orange border box around characters - visual-studio-code

When I type a ا letter in the Arabic language it is surrounded with a colored border box in vscode.
Any solution to this problem?

Your specific case - a series of Arabic characters - might no longer be highlighted in vscode (even with the following settings enabled) as vscode is getting a little smarter about strings of characters it would otherwise highlight.
Contextual Unicode Highlighting
To report fewer false positives, ambiguous and invisible unicode
characters are no longer highlighted if the surrounding characters
visually indicate a non-ASCII script.
Thus, in trusted workspaces, only characters that are invisible or can
be confused with ASCII characters are highlighted, except those that
are contained in a word of non-ASCII characters where at least one
character cannot be confused with an ASCII character.
from v1.65 Release notes; contextual unicode highlighting
Try disabling one or more of these settings (set to false):
Editor > Unicode Highlight: Non Basic ASCII
Editor > Unicode Highlight: Ambiguous Characters
also see https://stackoverflow.com/a/70293571/836330 for more on the Unicode Highlighting options. And https://stackoverflow.com/a/70297896/836330 and https://github.com/microsoft/vscode/issues/138767.
There is also a way in vscode v1.64 to add another locale to your environment so that its characters will not be highlighted as questionable unicode characters.
New setting: Editor > Unicode Highlight: Allowed Locales
Use this when your display language is something other than the language you are using in your files, like French, Russian, Japanese, etc. that is causing the unwanted unicode warning highlights.
Download the language pack you need:
Search in the Extensions view for "language packs". I believe only the Microsoft language packs are supported in the Allowed Locales at this time. The picture above shows the French Language Pack. Install it.
Add its language code to the Allowed Locales setting.
To find the right "code", the easiest is to open your Command Palette after installing the language pack and search for Configure Display Language. You don't want to change your display language but it will show the available language codes:
We see we need fr as the code.
It will make a setting like this in your settings.json:
"editor.unicodeHighlight.allowedLocales": {
"fr": true
}
Before these changes:
After: In theory, with the default options for the other unicode highlight setting, the unicode highlighting should be gone.
[It still seems a little rough to me, you may have different results.]

Related

Can I prevent splitting words on a single space in editors like atom, sublime text, and visual studio code?

Most text editors for writing code have settings that define which characters break words for things like keystroke navigation and tab-completion. Atom has a Non Word Characters field in the settings, Sublime Text has a JSON setting word_separators, and Visual Studio Code has a JSON setting editor.wordSeparators. There is some variation, but they all default to something similar to this backslash-escaped string
"`~!##$%^&*()-=+[{]}\\|;:'\",.<>/?"
None of them appear to include whitespace characters as word separators. This makes complete sense to me, but is it possible to prevent any of these editors (or an editor I haven't listed) from treating a single space as a word separator? I want to change this behavior because I have a special case where I'd like to tab-complete strings that contain single spaces.

vscode The character U+0647 "ه" could be confused with the character U+006f "o", which is more

vscode after update (November 2021 (version 1.63)) Unicode highlighting#
vscode highlight same persian words, I want add persian characters to allowed characters. but how?
Thank you if you can help me
"The character U+0647 "ه" could be confused with the character U+006f "o", which is more common in source code."
In the Editor > Unicode Highlight: Allowed Characters setting if you click on
Add Item you can paste or type your character in - but it appears you have to do it one by one which is sub-optimal. I tried inputting some unicode ranges but nothing worked.
I tested it for your ه character and it works. Once you paste it in, the value field will populate with true which is what you want.
The Ambiguous Characters setting shouldn't flag characters "common in the current user locale." Is ه such a character?
I don't see a Persian Language Pack in the Marketplace so perhaps there is no way to change your vscode language to Persian.
More on locales here: https://code.visualstudio.com/docs/getstarted/locales
You can also uncheck Settings > Editor > Unicode Highlight: Ambiguous Characters
It's so much easier than adding characters every single time.

How to find unicode characters that are not utf8 in VS Code?

I have unicode characters that I can't see, that are not utf8, I need to spot them.
I used the extension Highlight Bad Chars (Kevin Wenger) but it's not sufficient, in particular, I don't know which are these characters and I don't want to have to define them in advance.
How can I do this with VScode ?
Find [^\x00-\x7f] and Check use regular expressions.
Taken from Kon Blog
You can try the Gremlins extension which I found better than Highlight Bad Chars (Kevin Wenger) (at least, Gremlins worked out of the box; I couldn't get Highlight Bad Chars to highlight anything).
Also:
Gremlins Last updated: 11/5/2020
Highlight Bad Chars Last updated: 6/30/2018
In Stable Build v1.63 there is a new method for highlighting various unicode characters that might otherwise be difficult to spot in your code. These are the new settings:
You can use these colorCustomizations to change the default orange borders:
{
"workbench.colorCustomizations": {
"editorUnicodeHighlight.border": "#00ff37",
"editorUnicodeHighlight.background": "#f00", // will be in vscode v1.66
// "minimap.unicodeHighlight": "#ff0000", // removed in v1.64
// "editorOverviewRuler.unicodeForeground": "#ff0000" // removed in v1.64
}
Apparently, indicators for these unicode warnings will not be shown in the minimap or overview ruler as of v1.64, see Consider removing the unicode highlight scroll bar decoration
Here is how a unicode zero-width space appears with these settings:
The zero-width character is an invisible unicode character controlled by the Unicode Highlight: Invisible Characters setting above.
From v1.63 release notes: unicode highlighting
Read this article or this article for how invisible or confusable
Unicode characters can be used in Unicode spoofing attacks.
Note that this feature does not detect all possible Unicode spoofing
attacks, as this depends on your font and locale settings. Also, the
detection of ambiguous characters is done heuristically. To be on the
safe side, the restricted mode of the workspace trust should be used
to review source code, as all non-ASCII characters are highlighted in
untrusted workspaces.
The settings editor.unicodeHighlight.invisibleCharacters,
editor.unicodeHighlight.ambiguousCharacters or
editor.unicodeHighlight.nonBasicASCII can be set to false to disable
the corresponding feature.
Individual characters can be excluded from being highlighted and
characters in comments or text and markdown documents are not
highlighted by default.

Entering accented characters with notepad++ using only the keyboard

I am new to notepad++ and like it very much, since I can customize how my text documents look more easily than with wordpad. However, I would like to know if it’s possible to enter accented characters like in wordpad (I thought it was a windows thing, but perhaps it isn’t). In wordpad, I can type, for instance, ctrl-’ then i to get an accented í character. Similarly, I can type ctrl-shift-~ then n to get the accented ñ character. It makes it much easier to enter accented characters than copying and pasting from the character map application, or trying to remember code points. When I tried this method in notepad++ I just got the plain character without the accents. I should also mention that when I open documents with such accented characters already present they appear just as expected. Is there a way to enter accented characters like this in notepad++ using only the keyboard? I am using the latest notepad++ under Windows 7.
In Notepad++ you can go to “Edit” then select “Character Panel” near the bottom of the drop down menu. It will show you the ASCII set available which includes most accented characters. You find the character you want and there will be a number for it, to easily use that, press and hold your ALT key, then, on your keypad on the right side of your keyboard type zero followed by the number for that character. So for something like “ñ” for example, the code for it is 241, so you would press ALT and then type 0241 on the keypad while holding down ALT and you will get the character you need. That works in most Windows programs, even in here.
This only works for ASCII characters in the range of 0 to 255. I don't know of a method other than copying and pasting from the “Character Map” app available in Windows for Unicode. Though I did test Wordpad with the Decimal number of the Hex value you see for a Unicode character above 255 and it will work with the ALT+#### in there, and probably other places, but it doesn't work in Notepad or Notepad++ for some strange reason, sadly. Two I use a lot and have memorized are ALT+0147 and ALT+0148 for the quotation marks “like these”, so once you use the numbers enough you tend to get used to them, or you can jot down the ones you use the most.
For anyone searching for a solution and coming across this page, try this (Windows): install and use the US International keyboard instead of the plain US keyboard. Search for "windows keyboard us international install" or something similar. I liked the techlanguage.com write-up on it and the teckangaroo.com step by step on how to install. Hope this helps someone in future looking around as I was earlier today for how to easily meet this need.
You can make your own keyboard layout to enter arbitrary characters anywhere in Windows, using MSKLC. Here's one I made earlier.
I think it is configured in the input method. With input method containing the characters you mentioned, you can press key combinations to get special letters.
You can add a keyboard layout preset in Windows. Under "Language and Regions" - "Language" - "Language settings" - "Input method" settings in Control Panel, you can add all what you want. Like this:
Switch keyboard layout with Alt + Shift.

Russian characters not showing up correctly in MFC unicode list box

I have an MFC application compiled with MBCS set.
I have created a unicode list box on a regular MBCS dialog using the following code:
DWORD dwStyle = WS_CHILD|WS_VISIBLE|WS_VSCROLL;
hLangListBox = CreateWindowExW(WS_EX_CLIENTEDGE, //extended styles
_T(L"listbox"), //control 'class' name
L"Language", //control caption
dwStyle, //control style
10, //position: left
10, //position: top
200, //width
100, //height
GetSafeHwnd(), //parent window handle
//control's ID
reinterpret_cast<HMENU>(static_cast<INT_PTR>(ID_LANGUAGE_ENGLISH+20)),
AfxGetInstanceHandle(), //application instance
0);
When I inspect this dialog using Spy++ I see my Window Proc: has (Unicode) so I believe it is being created correctly.
I am populating the listbox with one of the following commands depending on if I have the data in a unicode string or a regular string
CStringW m_LanguageNames[MAX_LANG];
CString sFilename;
....
::SendMessageW(hLangListBox,LB_INSERTSTRING ,nMenuPos,reinterpret_cast<LPARAM>(theApp.m_LanguageNames[i].GetBuffer()));
::SendMessage(hLangListBox,LB_INSERTSTRING ,nMenuPos,reinterpret_cast<LPARAM>(sFileName.GetBuffer()));
Things look ok for most entries,
I can see
Chinese: 中文(简体)
French: Française
Japanese: 日本
but Russian looks like a P followed by a bunch of bars (P||||||), not Pусский. When I look at the contents of the CStringW in Visual Studio I do see the correct text.
Why can I see the other languages correctly and not russian? I am running on Windows 7 ultimate and compiling with Visual Studio 10
Edit
If I change my system locale to Russian I can see the russian characters fine. However, the ç in Française does not appear correct.
I thought unicode strings were independent of the system locale. Is that correct?
To populate my unicode CStringW I am doing:
CA2W tmp_wide(po.msgstr,CodePage);
m_LanguageNames[i] = tmp_wide;
where po.msgstr is a CString that was read in from a file. In this case, CodePage is set to 1251
If I inspect the variables in Visual Studio it appears that the conversion is happening correctly.
It appears that my unicode list box can display unicode characters from a MBCS such as Chinese fine, but that it can't display unicode characters from a SBCS that is different from my current code page.
Same problem, solved after a long time.
In my case the default font of dialog is set to "MS Sans Serif", just change to use the more recent font "Microsoft Sans Serif" and everything is resolved!
I have not solved this yet, but I think it is likely this is a font issue. I'm not going any farther with this, but the next step would be to have an owner drawn list box and specify an appropriate font for each language