How to find unicode characters that are not utf8 in VS Code? - visual-studio-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.

Related

IN vs code the double quotes and single quotes are being flags as errors why?

Why is it that the double quotes are being picked up as an error and I can't even use contractions words either because they are getting flagged as a issue? This has never been a issue before so why is it starting now?
It may be that your language is not recognizing the fancy quotes as allowable string delimiters and so the red underlining under the strings mat be fixed by changing those fancy quotes to normal quotes.
As of vscode v1.63: Just to know what those orange borders around the quote marks are, the fancy quotes are unexpected unicode characters. Those orange borders are warnings that there are unexpected or ambiguous unicode characters.
If you add those fancy quote characters to this setting:
Editor > Unicode Highlight: Allowed Characters
Just copy and paste your varioucs characters, like ” into the Add Item input.
Or you can disable this setting:
Editor > Unicode Highlight: Non Basic ASCII
and those warning borders will go away.
Unicode Highlighting of certain features was added to vscode recently.

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.

Fix issue With VS Code: yellow orange border box around characters

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.]

How can I use the original unicode characters for the four card suits in a jupyter notebook?

If I copy and paste the four symbols from the character selection panel (I'm on macOS) they change to the following: ♠️ ♣️ ♥️ ♦️, whereas I'd like the heart and diamond to be red.
EDIT: Interestingly, i've noticed that if I type the sequence 👁‍🗨♥️, and then I hit backspace when the cursor is between those two characters, they both transform into 👁‍♥️! (the same happens with the other three)
Can someone explain what is happening?
I guess this is because your browser doesn't know about these special characters. But I think you can check this page https://www.w3schools.com/charsets/ref_utf_symbols.asp
and replace special characters with unicode codes from page
or from this page http://graphemica.com/%E2%9D%A4

VSCode Extension createTextEditorDecorationType ignore whitespace

I'm working on an extension which colors some text within the editor based on some condition. Unfortunately, it looks like the style applied to the text is also applied to the whitespace characters when the user has editor.renderWhitespace enabled.
I can't find anything in the API which gives the option of ignoring the whitespace when coloring.
Does anyone know of a way to leave the color of the whitespace characters intact?
There is a setting to change the color and opacity of whitespace characters when made visible as discussed here. It says that you could use:
"workbench.colorCustomizations": {
"editorWhitespace.foreground": "#FF0000"
}
The colors for the whitespace is taken from the invisibles property in themes, so the color is customizable via themes.
<key>invisibles</key>
<string>#3B3A32</string>
for more information please read this issue here