Set windows default encoding to utf 8

is there a way to set Windows 7 to globally use UTF-8 as standard? its really annoying to set every single text editor to use it.

The short answer is no, it is not possible.

To elaborate, I am afraid you won’t find a global encoding option in Windows 7 that lets you both 1) set a global default which 2) all the applications you listed would obey.

Also, I would like to ask what is the problem here that you are trying to solve?

It is up to the application to choose whether they use unicode internally to represent data. While use of unicode is encouraged, you may never be sure that all your applications in fact do internally support it.

What you can do, however is change the default character encoding for each of the listed applications:

  • For Eclipse, default encoding for new files can be set from Windows > Preferences > General > Content Types (see post on Eclipse Community Forms)
  • For Notepad++, navigate to Settings > Preferences > New Document/Default/Directory and set Encoding to UTF-8
  • As for Thunderbird, I am pretty sure it already uses UTF-8 as the default encoding? (see these notes about character encoding)
  • In the case of OpenOffice (and LibreOffice), you actually don’t even need to care about encoding, since documents saved by OpenOffice are based on XML, in which encoding is specified internally in the XML-files (and UTF-8 is already the default there as well)
  • From UTF-8 point-of-view, PowerShell is tricky. It has default encoding of UTF-16LE.
    • For outputting files from PowerShell to UTF-8, see this answer
    • For changing default encoding see this answer

View the System Locale settings for Windows

  1. Click Start then Control Panel.
  2. Click Clock, Language and Region.
  3. Windows 10, Windows 8: Click Region. …
  4. Click the Administrative tab. …
  5. Under the Language for non-Unicode programs section, click Change system locale and select the desired language.
  6. Click OK.

How do I change my default encoding?

2 Answers

  1. For Eclipse, default encoding for new files can be set from Windows > Preferences > General > Content Types (see post on Eclipse Community Forms)
  2. For Notepad++, navigate to Settings > Preferences > New Document/Default/Directory and set Encoding to UTF-8.

What is the default encoding in Windows 10?

The default character encoding is assumed to be UTF-8 on Windows. So if the default operating system Locale is “English_USA. 1252” the default locale for Boost.

How do you change Windows default encoding to UTF-8?

Open Windows Control Panel -> Region. Go to the Administrative tab and click Change system locale… Remove the check mark next to Beta: Use UTF-8 for worldwide language support. Click OK and restart your computer.

Does Windows 10 use UTF8?

Starting in Windows 10 build 17134 (April 2018 Update), the Universal C Runtime supports using a UTF-8 code page. This means that char strings passed to C runtime functions will expect strings in the UTF-8 encoding. … For Windows 10 operating systems prior to 17134, only static linking is supported.

How do I change file encoding in Windows?

Choose an encoding standard when you open a file

  1. Click the File tab.
  2. Click Options.
  3. Click Advanced.
  4. Scroll to the General section, and then select the Confirm file format conversion on open check box. …
  5. Close and then reopen the file.
  6. In the Convert File dialog box, select Encoded Text.

What is the default encoding for notepad?

Notepad normally uses ANSI encoding, so if it reads the file as UTF-8 then it has to guess the encoding based on the data in the file. If you save a file as UTF-8, Notepad will put the BOM (byte order mark) EF BB BF at the beginning of the file.

How do I change the default encoding to UTF-8 in Excel?

Click Tools, then select Web options. Go to the Encoding tab. In the dropdown for Save this document as: choose Unicode (UTF-8). Click Ok.

Why do we use UTF-8 encoding?

Why use UTF-8? An HTML page can only be in one encoding. You cannot encode different parts of a document in different encodings. A Unicode-based encoding such as UTF-8 can support many languages and can accommodate pages and forms in any mixture of those languages.

What is difference between UTF-8 and utf16?

The Difference

Utf-8 and utf-16 both handle the same Unicode characters. They are both variable length encodings that require up to 32 bits per character. The difference is that Utf-8 encodes the common characters including English and numbers using 8-bits. Utf-16 uses at least 16-bits for every character.

What is the default encoding for Excel?

From memory, Excel uses the machine-specific ANSI encoding. So this would be Windows-1252 for a EN-US installation, 1251 for Russian, etc.

How do I change the default encoding in Notepad ++?

go to the notepad++ menu settings > preferences > misc. and disable autodetect character encoding as seen at the screenshot below. then go to settings > preferences > new document and set encoding to your prefered encoding.

How do I change ANSI TO UTF-8?

Try Settings -> Preferences -> New document -> Encoding -> choose UTF-8 without BOM, and check Apply to opened ANSI files . That way all the opened ANSI files will be treated as UTF-8 without BOM.

How do I change my Windows locale?

System Locale

  1. Select Start > Control Panel > Clock, Language, and Region > Region and Language.
  2. Open Administrative tab.
  3. In the Language for non-Unicode programs section, click Change system locale….
  4. Select a target locale from the Current system locale drop-down list.
  5. Restart the system.

What character encoding does Windows use?

The character set most commonly used in computers today is Unicode, a global standard for character encoding. Internally, Windows applications use the UTF-16 implementation of Unicode. In UTF-16, most characters are identified by two-byte codes.

Как исправить кириллицу в Windows 10Одна из возможных проблем, с которыми можно столкнуться после установки Windows 10 — кракозябры вместо русских букв в интерфейсе программ, а также в документах. Чаще неправильное отображение кириллицы встречается в изначально англоязычных и не совсем лицензионных версиях системы, но бывают и исключения.

В этой инструкции — о том, как исправить «кракозябры» (или иероглифы), а точнее — отображение кириллицы в Windows 10 несколькими способами. Возможно, также будет полезным: Как установить и включить русский язык интерфейса в Windows 10 (для систем на английском и других языках).

Исправление отображения кириллицы с помощью настроек языка и региональных стандартов Windows 10

Кракозябры в программах и документах Windows 10

Самый простой и чаще всего работающий способ убрать кракозябры и вернуть русские буквы в Windows 10 — исправить некоторые неправильные настройки в параметрах системы.

Для этого потребуется выполнить следующие шаги (примечание: привожу также названия нужных пунктов на английском, так как иногда необходимость исправить кириллицу возникает в англоязычных версиях системы без нужды менять язык интерфейса).

  1. Откройте панель управления (для этого можно начать набирать «Панель управления» или «Control Panel» в поиске на панели задач.
  2. Убедитесь, что в поле «Просмотр» (View by) установлено «Значки» (Icons) и выберите пункт «Региональные стандарты» (Region). Региональные стандарты в Windows 10
  3. На вкладке «Дополнительно» (Administrative) в разделе «Язык программ, не поддерживающих Юникод» (Language for non-Unicode programs) нажмите по кнопке «Изменить язык системы» (Change system locale). Дополнительные параметры языка системы
  4. Выберите русский язык, нажмите «Ок» и подтвердите перезагрузку компьютера. Установка региона Россия для Windows 10

После перезагрузки проверьте, была ли решена проблема с отображением русских букв в интерфейсе программ и (или) документах — обычно, кракозябры бывают исправлены после этих простых действий.

Отображение кириллицы исправлено в Windows 10

Как исправить иероглифы Windows 10 путем изменения кодовых страниц

Кодовые страницы представляют собой таблицы, в которых определенным байтам сопоставляются определенные символы, а отображение кириллицы в виде иероглифов в Windows 10 связано обычно с тем, что по умолчанию задана не та кодовая страница и это можно исправить несколькими способами, которые могут быть полезны, когда требуется не изменять язык системы в параметрах.

С помощью редактора реестра

Первый способ — использовать редактор реестра. На мой взгляд, это самый щадящий для системы метод, тем не менее, рекомендую создать точку восстановления прежде чем начинать. Совет про точки восстановления относится и ко всем последующим способам в этом руководстве.

  1. Нажмите клавиши Win+R на клавиатуре, введите regedit и нажмите Enter, откроется редактор реестра.
  2. Перейдите к разделу реестра
    HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlNlsCodePage

    и в правой части пролистайте значения этого раздела до конца. Установленный регион Windows 10 в реестре

  3. Дважды нажмите по параметру ACP, установите значение 1251 (кодовая страница для кириллицы), нажмите Ок и закройте редактор реестра. Изменение кодовой страницы на кириллицу
  4. Перезагрузите компьютер (именно перезагрузка, а не завершение работы и включение, в Windows 10 это может иметь значение).

Обычно, это исправляет проблему с отображением русских букв. Вариация способа с помощью редактора реестра (но менее предпочтительная) — посмотреть на текущее значение параметра ACP (обычно — 1252 для изначально англоязычных систем), затем в том же разделе реестра найти параметр с именем 1252 и изменить его значение с c_1252.nls на c_1251.nls.

Кодовые страницы в реестре Windows 10

Путем подмена файла кодовой страницы на c_1251.nls

Второй, не рекомендуемый мной способ, но иногда выбираемый теми, кто считает, что правка реестра — это слишком сложно или опасно: подмена файла кодовой страницы в C: Windows System32 (предполагается, что у вас установлена западно-европейская кодовая страница — 1252, обычно это так. Посмотреть текущую кодовую страницу можно в параметре ACP в реестре, как было описано в предыдущем способе).

  1. Зайдите в папку C: Windows System32 и найдите файл c_1252.NLS, нажмите по нему правой кнопкой мыши, выберите пункт «Свойства» и откройте вкладку «Безопасность». На ней нажмите кнопку «Дополнительно». Просмотр параметров безопасности файла
  2. В поле «Владелец» нажмите «Изменить». Изменение владельца C_1252.nls
  3. В поле «Введите имена выбираемых объектов» укажите ваше имя пользователя (с правами администратора). Если в Windows 10 используется учетная запись Майкрософт, вместо имени пользователя укажите адрес электронной почты. Нажмите «Ок» в окне, где указывали пользователя и в следующем (Дополнительные параметры безопасности) окне. Указание владельца для файла
  4. Вы снова окажетесь на вкладке «Безопасность» в свойствах файла. Нажмите кнопку «Изменить».
  5. Выберите пункт «Администраторы» (Administrators) и включите полный доступ для них. Нажмите «Ок» и подтвердите изменение разрешений. Нажмите «Ок» в окне свойств файла. Установить полный доступ к файлу для Администраторы
  6. Переименуйте файл c_1252.NLS (например, измените расширение на .bak, чтобы не потерять этот файл).
  7. Удерживая клавишу Ctrl, перетащите находящийся там же в C:WindowsSystem32 файл c_1251.NLS (кодовая страница для кириллицы) в другое место этого же окна проводника, чтобы создать копию файла. Копия файла C_1251.nls
  8. Переименуйте копию файла c_1251.NLS в c_1252.NLS.
  9. Перезагрузите компьютер.

После перезагрузки Windows 10 кириллица должна будет отображаться не в виде иероглифов, а как обычные русские буквы.

Let me try to summarize, now that we (hopefully) have the full picture:

I’ve hidden my previous comments in favor of this one, @nu8 — I encourage you to do the same, as appropriate. This comment also corrects my incorrect earlier claim that you cannot set the ANSI code page to 65001.

This issue is about making UTF-8 support in PowerShell on Windows complete, by making sure that PowerShell also uses UTF-8 when communicating with external programs (the built-in cmdlets already default to UTF-8, invariably so), which requires setting [console]::InputEncoding and [console]::OutputEncoding to (BOM-less) UTF-8 (possibly indirectly).


Currently, in the absence of PowerShell doing that itself, there are two workarounds:

Option 1: Put the following statement in your $PROFILE:

# In *Windows PowerShell*, prepend `$OutputEncoding = `
[console]::InputEncoding = [console]::OutputEncoding = [System.Text.UTF8Encoding]::new()

Pros and cons:

  • Doesn’t require administrative privileges and takes effect in new windows without the need for a reboot.
  • Requires modifying $PROFILE
  • Is bypassed if the CLI is used as pwsh -noprofile ...

Note: In Windows PowerShell, you must prepend $OutputEncoding = to the above command, in order to also make Windows PowerShell send UTF-8 to external programs. (In PowerShell [Core], this preference variably commendably defaults to (BOM-less) UTF-8.)


Option 2: Change the active code pages to 65001 system-wide (W10+):

  • GUI method: via intl.cpl (Control Panel), tab Administrative, Change system locale...); as previously noted, this is still labeled as Beta: as of Windows 10 release 1909, though I suspect it will work fine as long as you use only modern command-line utilities.

  • Equivalent programmatic method, based on @nu8’s approach:

# Requires ELEVATION and a REBOOT
'ACP', 'OEMCP', 'MACCP' | Set-ItemProperty HKLM:SYSTEMCurrentControlSetControlNlsCodePage -Name { $_ } 65001
# Restart-Computer

Pros and cons:

  • Due to a .NET bug still present in the .NET version underlying PowerShell Core 7.1.0-preview.3, [console]::InputEncoding and [console]::OutputEncoding are mistakenly set to UTF-8 encoding with BOM, which causes follow-on bugs; notably, it breaks Start-Job in PowerShell. See System.Console unexpectedly uses a UTF-8 encoding *with BOM* on Windows dotnet/runtime#28929. Option 1 above doesn’t have this problem.

    • Curiously, by contrast, the [System.Text.Encoding]::Default encoding that reflects the active ANSI code page contains a BOM-less UTF-8 encoding after the system-wide change (see below).

    • Note that the bug can also manifest without the system-wide change, namely if you manually run chcp 65001 from cmd.exe, for instance, before invoking PowerShell (running chcp from inside PowerShell isn’t supported and requires Option 1 instead).

  • Requires administrative privileges and a reboot.

  • Takes effect system-wide: it applies to all console / Windows Terminal windows, notably including those running cmd.exe

  • Invariably also uses UTF-8 as the ANSI code page (not just the OEM code page), as reflected in [System.Text.Encoding]::Default (note that this also applies if you set only the OEMCP registry value to 65001; (Get-Culture).TextInfo.ANSICodePage, by contrast, continues to report the locale-appropriate code page, e.g. 1252).

    • If you’re (also) running Windows PowerShell, this means that the setting invariably makes Windows PowerShell‘s ANSI-encoding-default cmdlets default to UTF-8, notably Get-Content and Set-Content, which, depending on your backward-compatibility needs:
      • may be desirable for consistent UTF-8 use across both PowerShell editions.
        • Note: short of placing $PSDefaultParameterValues['*:Encoding'] = 'utf8' in your $PROFILE, this is the only way to get Windows PowerShell to consistently default to UTF-8.
          Curiously, the system-wide change causes Windows PowerShell to then create BOM-less UTF-8 files by default with Set-Content, something that cannot otherwise achieved, except with direct use of .NET.
      • may be undesired, if you have existing code that uses Get-Content and Set-Content without -Encoding and you need to process BOM-less files that are ANSI- rather than UTF-8-encoded.
    • Also, in Windows PowerShell only, you must additionally still run
      $OutputEncoding = [System.Text.Utf8Encoding]::new() (via $PROFILE) in order to also make Windows PowerShell send UTF-8 to external programs.

A note on file encoding:

If making Windows PowerShell too default to UTF-8 via the system-wide change is not an option, BOM-less UTF-8 files will only be read correctly under one of the following conditions:

  • you use -Encoding Utf8 with file-handling cmdlets.

  • you convert your BOM-less UTF-8 files to have a BOM

    • such files can be problematic in cross-platform use; on Unix-like platforms, a UTF-8 BOM can be misinterpreted as data
    • conversely, if you write PowerShell code that contains (runtime-relevant) non-ASCII characters and needs to run in both editions, saving your source code files as UTF-8 with BOM is a must (though you could also use UTF-16).
  • you preset the default encoding via $PSDefaultParameterValues['*:Encoding'] = 'utf8', but you’ll have to scope this setting if you don’t want all code to use these defaults.

Note that Windows PowerShell — curiously, except if the system-wide change is made — only ever creates UTF-8 files with BOM (whereas PowerShell [Core] defaults to BOM-less UTF-8 and has an -Encoding utf8BOM opt-in); direct use of .NET is required to work around that — see this SO answer.

  1. Unicode in PowerShell
  2. Change System Locale to Use UTF-8 Encoding in Windows PowerShell
  3. Set Encoding in $PSDefaultParameterValues Variable to Use UTF-8 Encoding in Windows PowerShell

UTF-8 Encoding (CHCP 65001) in PowerShell

This tutorial will teach you to use UTF-8 encoding in Windows PowerShell.

Unicode in PowerShell

Unicode is a worldwide character encoding standard. It defines how characters in text files, web pages, and other documents are represented.

The computer system uses Unicode to manipulate characters and strings. The default encoding in PowerShell is Windows-1252.

Unicode was developed to support characters from all languages of the world. PowerShell supports a Unicode character encoding by default.

UTF-8 and UTF-16 are the most common Unicode encodings. PowerShell always uses BOM in all Unicode encodings except UTF7.

The BOM (byte-order-mark) is a Unicode signature included at the first few bytes of a file or text stream that indicates the Unicode encoding.

Change System Locale to Use UTF-8 Encoding in Windows PowerShell

There is an option to change the system locale (current language for non-Unicode programs) in Windows. But this feature is still in beta.

Go to Region Settings from the Control Panel or open intl.cpl from the Run program.

change system locale to use UTF-8 encoding in PowerShell

Open the Administrative tab and click Change system locale. Then check the Beta option as shown in the image below.

use unicode UTF-8 for worldwide language support

After that, press OK and restart the computer to apply the settings.

After restarting the computer, you can check the $OutputEncoding variable to view the current encoding.

Output:

As you can see, the current encoding is Unicode (UTF-8).

BodyName          : utf-8
EncodingName      : Unicode (UTF-8)
HeaderName        : utf-8
WebName           : utf-8
WindowsCodePage   : 1200
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
IsSingleByte      : False
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 65001

Now, you can view the characters of other languages in PowerShell.

Output:

Set Encoding in $PSDefaultParameterValues Variable to Use UTF-8 Encoding in Windows PowerShell

You can run the following command to activate the UTF-8 encoding in PowerShell.

$PSDefaultParameterValues = @{'*:Encoding' = 'utf8'}

It is only valid for the current PowerShell console. It will be reset to default after you exit the PowerShell window.

Output:

Several cmdlets in PowerShell have the -Encoding parameter to specify the encoding for different character sets. Some of them are Add-Content, Set-Content, Get-Content, Export-Csv, Out-File, etc.

The -Encoding parameter supports these values: ascii, bigendianunicode, oem, unicode, utf7, utf8 ,utf8BOM, utf8NoBOM, utf32.

We hope this tutorial gave you an idea of using UTF-8 Encoding (CHCP 65001) in Windows PowerShell.

Понравилась статья? Поделить с друзьями:
  • Set property system windows resourcedictionary source threw an exception
  • Set key hklm software microsoft windows currentversion runonceex
  • Set java home windows 10 from cmd
  • Set java home variable windows 10
  • Set executionpolicy windows powershell updated your execution policy successfully