Windows 8 utf 8 support

From Wikipedia, the free encyclopedia

Microsoft was one of the first companies to implement Unicode in their products. Windows NT was the first operating system that used «wide characters» in system calls. Using the (now obsolete) UCS-2 encoding scheme at first, it was upgraded to the variable-width encoding UTF-16 starting with Windows 2000, allowing a representation of additional planes with surrogate pairs. However Microsoft did not support UTF-8 in its API until May 2019.

Before 2019, Microsoft emphasized UTF-16 (i.e. -W API), but has since recommended to use UTF-8 (at least in some cases),[1] on Windows and Xbox (and in other of its products), even states «UTF-8 is the universal code page for internationalization [and] UTF-16 [..] a unique burden that Windows places on code that targets multiple platforms. [..] Windows [is] moving forward to support UTF-8 to remove this unique burden [resulting] in fewer internationalization issues in apps and games».[2]

A large amount of Microsoft documentation uses the word «Unicode» to refer explicitly to the UTF-16 encoding. Anything else, including UTF-8, is not «Unicode» in Microsoft’s outdated language (while UTF-8 and UTF-16 are both Unicode according to the Unicode Standard, or encodings/»transformation formats» of).

In various Windows families[edit]

Windows NT based systems[edit]

Current Windows versions and all back to Windows XP and prior Windows NT (3.x, 4.0) are shipped with system libraries that support string encoding of two types: 16-bit «Unicode» (UTF-16 since Windows 2000) and a (sometimes multibyte) encoding called the «code page» (or incorrectly referred to as ANSI code page). 16-bit functions have names suffixed with ‘W’ (from «wide») such as SetWindowTextW. Code page oriented functions use the suffix ‘A’ for «ANSI» such as SetWindowTextA (some other conventions were used for APIs that were copied from other systems, such as _wfopen/fopen or wcslen/strlen). This split was necessary because many languages, including C, did not provide a clean way to pass both 8-bit and 16-bit strings to the same function.

Microsoft attempted to support Unicode «portably» by providing a «UNICODE» switch to the compiler, that switches unsuffixed «generic» calls from the ‘A’ to the ‘W’ interface and converts all string constants to «wide» UTF-16 versions.[3][4] This does not actually work because it does not translate UTF-8 outside of string constants, resulting in code that attempts to open files just not compiling.[citation needed]

Earlier, and independent of the «UNICODE» switch, Windows also provided the Multibyte Character Sets (MBCS) API switch.[5] This changes some functions that don’t work in MBCS such as strrev to an MBCS-aware one such as _mbsrev.[6][7]

Windows CE[edit]

In (the now discontinued) Windows CE, UTF-16 was used almost exclusively, with the ‘A’ API mostly missing.[8] A limited set of ANSI API is available in Windows CE 5.0, for use on a reduced set of locales that may be selectively built onto the runtime image.[9]

[icon]

This section needs expansion. You can help by adding to it. (June 2011)

Windows 9x[edit]

In 2001, Microsoft released a special supplement to Microsoft’s old Windows 9x systems. It includes a dynamic link library, ‘unicows.dll’, (only 240 KB) containing the 16-bit flavor (the ones with the letter W on the end) of all the basic functions of Windows API. It is merely a translation layer: SetWindowTextW will simply convert its input using the current codepage and call SetWindowTextA.

UTF-8[edit]

Microsoft Windows (Windows XP and later) has a code page designated for UTF-8, code page 65001[10] or CP_UTF8. For a long time, it was impossible to set the locale code page to 65001, leaving this code page only available for (a) explicit conversion functions such as MultiByteToWideChar and/or (b) the Win32 console command chcp 65001 to translate stdin/out between UTF-8 and UTF-16. This meant that «narrow» functions, in particular fopen (which opens files), couldn’t be called with UTF-8 strings, and in fact there was no way to open all possible files using fopen no matter what the locale was set to and/or what bytes were put in the string, as none of the available locales could produce all possible UTF-16 characters. This problem also applied to all other APIs that take or return 8-bit strings, including Windows ones such as SetWindowText.

Programs that wanted to use UTF-8, in particular code intended to be portable to other operating systems, needed a workaround for this deficiency. The usual work-around was to add new functions to open files that convert UTF-8 to UTF-16 using MultiByteToWideChar and call the «wide» function instead of fopen.[11] Dozens of multi-platform libraries added wrapper functions to do this conversion on Windows (and pass UTF-8 through unchanged on others), an example is a proposed addition to Boost, Boost.Nowide.[12] Another popular work-around was to convert the name to the 8.3 filename equivalent, this is necessary if the fopen is inside a library. None of these workarounds are considered good, as they require changes to the code that works on non-Windows.

In April 2018 (or possibly November 2017[13]), with insider build 17035 (nominal build 17134) for Windows 10, a «Beta: Use Unicode UTF-8 for worldwide language support» checkbox appeared for setting the locale code page to UTF-8.[a] This allows for calling «narrow» functions, including fopen and SetWindowTextA, with UTF-8 strings. However this is a system-wide setting and a program cannot assume it is set.

In May 2019, Microsoft added the ability for a program to set the code page to UTF-8 itself,[1][14] allowing programs written to use UTF-8 to be run by non-expert users.

As of 2019, Microsoft recommends programmers use UTF-8 (e.g. instead of any other 8-bit encoding),[1] on Windows and Xbox, and may be recommending its use instead of UTF-16, even stating «UTF-8 is the universal code page for internationalization [and] UTF-16 [..] is a unique burden that Windows places on code that targets multiple platforms.»[2] Microsoft does appear to be transitioning to UTF-8, stating it previously emphasized its alternative, and in Windows 11 some system files are required to use UTF-8 and do not require a Byte Order Mark.[15] Notepad can now recognize UTF-8 without the Byte Order Mark, and can be told to write UTF-8 without a Byte Order Mark.[citation needed] Some other Microsoft products are using UTF-8 internally, including Visual Studio[citation needed] and their SQL Server 2019, with Microsoft claiming 35% speed increase from use of UTF-8, and «nearly 50% reduction in storage requirements.»[16]

Programming platforms[edit]

Microsoft’s compilers often fail at producing UTF-8 string constants from UTF-8 source files. The most reliable method is to turn off UNICODE, not mark the input file as being UTF-8 (i.e. do not use a BOM), and arrange the string constants to have the UTF-8 bytes. If a BOM was added, a Microsoft compiler will interpret the strings as UTF-8, convert them to UTF-16, then convert them back into the current locale, thus destroying the UTF-8.[17] Without a BOM and using a single-byte locale, Microsoft compilers will leave the bytes in a quoted string unchanged. On modern systems setting the code page to UTF-8 helps considerably, but invalid byte sequences are still not preserved (using \x can work around this).

See also[edit]

  • Bush hid the facts, a text encoding mojibake

Notes[edit]

  1. ^ Found under control panel, «Region» entry, «Administrative» tab, «Change system locale» button.

References[edit]

  1. ^ a b c «Use UTF-8 code pages in Windows apps». learn.microsoft.com. Retrieved 2020-06-06. As of Windows version 1903 (May 2019 update), you can use the ActiveCodePage property in the appxmanifest for packaged apps, or the fusion manifest for unpackaged apps, to force a process to use UTF-8 as the process code page. […] CP_ACP equates to CP_UTF8 only if running on Windows version 1903 (May 2019 update) or above and the ActiveCodePage property described above is set to UTF-8. Otherwise, it honors the legacy system code page. We recommend using CP_UTF8 explicitly.
  2. ^ a b «UTF-8 support in the Microsoft Game Development Kit (GDK) — Microsoft Game Development Kit». learn.microsoft.com. 19 August 2022. Retrieved 2023-03-05. By operating in UTF-8, you can ensure maximum compatibility [..] Windows operates natively in UTF-16 (or WCHAR), which requires code page conversions by using MultiByteToWideChar and WideCharToMultiByte. This is a unique burden that Windows places on code that targets multiple platforms. [..] The Microsoft Game Development Kit (GDK) and Windows in general are moving forward to support UTF-8 to remove this unique burden of Windows on code targeting or interchanging with multiple platforms and the web. Also, this results in fewer internationalization issues in apps and games and reduces the test matrix that’s required to get it right.
  3. ^ «Unicode in the Windows API». Retrieved 7 May 2018.
  4. ^ «Conventions for Function Prototypes (Windows)». MSDN. Retrieved 7 May 2018.
  5. ^ «Support for Multibyte Character Sets (MBCSs)». Retrieved 2020-06-15.
  6. ^ «Double-byte Character Sets». MSDN. 2018-05-31. Retrieved 2020-06-15. our applications use DBCS Windows code pages with the «A» versions of Windows functions.
  7. ^ _strrev, _wcsrev, _mbsrev, _mbsrev_l Microsoft Docs
  8. ^ «Differences Between the Windows CE and Windows NT Implementations of TAPI». MSDN. 28 August 2006. Retrieved 7 May 2018. Windows CE is Unicode-based. You might have to recompile source code that was written for a Windows NT-based application.
  9. ^ «Code Pages (Windows CE 5.0)». Microsoft Docs. 14 September 2012. Retrieved 7 May 2018.
  10. ^ «Code Page Identifiers (Windows)». msdn.microsoft.com. 7 January 2021.
  11. ^ «UTF-8 in Windows». Stack Overflow. Retrieved July 1, 2011.
  12. ^ «Boost.Nowide». GitHub.
  13. ^ «Windows10 Insider Preview Build 17035 Supports UTF-8 as ANSI». Hacker News. Retrieved 7 May 2018.
  14. ^ «Windows 10 1903 and later versions finally support UTF-8 with the A forms of the Win32 functions».
  15. ^ «Customize the Windows 11 Start menu». docs.microsoft.com. Retrieved 2021-06-29. Make sure your LayoutModification.json uses UTF-8 encoding.
  16. ^ «Introducing UTF-8 support for SQL Server». techcommunity.microsoft.com. 2019-07-02. Retrieved 2021-08-24. For example, changing an existing column data type from NCHAR(10) to CHAR(10) using an UTF-8 enabled collation, translates into nearly 50% reduction in storage requirements. [..] In the ASCII range, when doing intensive read/write I/O on UTF-8, we measured an average 35% performance improvement over UTF-16 using clustered tables with a non-clustered index on the string column, and an average 11% performance improvement over UTF-16 using a heap.
  17. ^ UTF-8 Everywhere FAQ: How do I write UTF-8 string literal in my C++ code?

External links[edit]

  • «Unicode». MSDN. Microsoft. Retrieved November 10, 2016.

Аватара пользователя

Natalia Novoselova

Гуру

Сообщения: 3020
Зарегистрирован: 15 янв 2013, 20:14

Репутация: 69
Ваше звание: Лиса
Откуда: **
Контактная информация:

Как поставить кодировку UTF-8 в Windows-8

Есть скрипт для R, где комментарии написаны на русском языке в кодировке UTF-8. При открытии скрипта у меня крякозябы, несмотря на то, что в систем на компе язык «для приложений не использующих Unicode» стоит русский. То есть — надо поставить еще кодировку UTF-8. Как это сделать для всей ОС (Windows-8)? Нигде не могу найти таких настроек. В самом R тоже.


Аватара пользователя

Игорь Белов

Гуру

Сообщения: 2216
Зарегистрирован: 04 янв 2011, 22:00
Статьи: 12
Проекты: 1

Репутация: 1499
Откуда: Казань

Re: Как поставить кодировку UTF-8 в Windows-8

Сообщение

Игорь Белов » 27 окт 2018, 21:24

Проще всего перекодировать файл в CP1251. Это можно сделать в большинстве текстовых редакторов. Или погуглите онлайн-конвертеры.

The purpose of computing is insight, not numbers


Аватара пользователя

rhot

Гуру

Сообщения: 1727
Зарегистрирован: 25 янв 2011, 17:50
Статьи: 1

Репутация: 194
Ваше звание: доктор
Откуда: Архангельск

Re: Как поставить кодировку UTF-8 в Windows-8

Сообщение

rhot » 27 окт 2018, 21:26

В RStudio кодировка выбирается через File —> Reopen with encoding

___________(¯`·.¸(¯`·.¸ Scientia potentia est _/ {SILVA}:::{FOSS}:::{GIS} \_ Знание сила ¸.·´¯)¸.·´¯)___________


Аватара пользователя

Natalia Novoselova

Гуру

Сообщения: 3020
Зарегистрирован: 15 янв 2013, 20:14

Репутация: 69
Ваше звание: Лиса
Откуда: **
Контактная информация:

Re: Как поставить кодировку UTF-8 в Windows-8

Сообщение

Natalia Novoselova » 30 окт 2018, 22:09

Игорь Белов писал(а): ↑

27 окт 2018, 21:24

Проще всего перекодировать файл в CP1251. Это можно сделать в большинстве текстовых редакторов. Или погуглите онлайн-конвертеры.

Почему-то на моем компе такая перезапись скрипта тоже дала крякозябы.

В RStudio кодировка выбирается через File —> Reopen with encoding

Я пользуюсь обычной R консолью, там такого нет. Попробую перейти в RStudio.


Аватара пользователя

rhot

Гуру

Сообщения: 1727
Зарегистрирован: 25 янв 2011, 17:50
Статьи: 1

Репутация: 194
Ваше звание: доктор
Откуда: Архангельск

Re: Как поставить кодировку UTF-8 в Windows-8

Сообщение

rhot » 31 окт 2018, 10:25

Natalia Novoselova писал(а): ↑

30 окт 2018, 22:09

Я пользуюсь обычной R консолью, там такого нет. Попробую перейти в RStudio.

Тогда не знаю как. Могу предложить последовать примеру редактирования реестра. Правда это для семёрки…

___________(¯`·.¸(¯`·.¸ Scientia potentia est _/ {SILVA}:::{FOSS}:::{GIS} \_ Знание сила ¸.·´¯)¸.·´¯)___________


gamm

Гуру

Сообщения: 3979
Зарегистрирован: 15 окт 2010, 08:33

Репутация: 1035
Ваше звание: программист
Откуда: Казань

Re: Как поставить кодировку UTF-8 в Windows-8

Сообщение

gamm » 31 окт 2018, 14:05

Поставьте FAR (он бесплатный), откройте файл во встроенном редакторе, выберите исходную кодировку (если не распознает), выделите все (Ctrl/a), уберите в буфер (ctrl/x), выберите новую кодировку, и вставьте (ctrl/v).

Выбор кодировки типа ctrl/F8 или alt/F8 или около. Если нужной кодировки нет, установите, в папке, где far стоит, есть скрипты.


nplatonov

Интересующийся

Сообщения: 25
Зарегистрирован: 07 фев 2012, 12:00

Репутация: 20

Re: Как поставить кодировку UTF-8 в Windows-8

Сообщение

nplatonov » 04 ноя 2018, 20:42

Можно попробовать задавать кодировку следующим образом:
path_to_R_bin\Rterm —encoding UTF-8 —file=test.R —args pi 3.1415


nkljdubin

Новоприбывший

Сообщения: 0
Зарегистрирован: 13 мар 2021, 05:44

Репутация: 0
Откуда: Санкт-Петербу́рг
Контактная информация:

Re: Как поставить кодировку UTF-8 в Windows-8

Сообщение

nkljdubin » 13 мар 2021, 05:49

Тоже интересовался данным вопросом, спасибо за советы.


AlexTim

Интересующийся

Сообщения: 35
Зарегистрирован: 25 ноя 2021, 14:11

Репутация: 9
Откуда: Оренбург

Re: Как поставить кодировку UTF-8 в Windows-8

Сообщение

AlexTim » 22 дек 2021, 13:36

Изображение
Попробуйте
«Панель управления» —> «Региональные стандарты» —> «Дополнительно» —> [«Изменить язык системы»] —>
(v) «Использовать Юникод (UTF-8) для поддержки языка во всем Мире».
Перезагрузка.


We know there is an application called AppLocale, which can change the code page of non-Unicode applications, to solve text display problems.

But there is a program whose right display code page is UTF-8, which means its text should be shown as UTF-8, but instead Windows displays it as the native code page and makes the text unreadable. It seems funny, because there are almost all countries and regions, but without UTF-8. I think it is a bug, because the programmers may use English and ignore testing non-English text display issues. I don’t think the producer will fix it and I wanna fix it myself.

Is it possible to set non-Unicode output as UTF-8 by using software like AppLocale? Default non-Unicode output is native code page? How can I set the native code page to UTF-8?

phuclv's user avatar

phuclv

26.7k15 gold badges115 silver badges235 bronze badges

asked Jan 29, 2016 at 15:23

Komeiji Kuroko's user avatar

1

Previously it was not possible because

Microsoft claimed a UTF-8 locale might break some functions (a possible example is _mbsrev) as they were written to assume multibyte encodings used no more than 2 bytes per character, thus until now code pages with more bytes such as GB 18030 (cp54936) and UTF-8 could not be set as the locale.

https://en.wikipedia.org/wiki/Unicode_in_Microsoft_Windows#UTF-8

However there’s a «Beta: Use Unicode UTF-8 for worldwide language support» checkbox since Windows 10 insider build 17035 for setting the locale code page to UTF-8

Beta: Use Unicode UTF-8 for worldwide language support

See also

  • Changing ansi and OEM code page in Windows
  • Windows 10 Insider Preview Build 17035 Supports UTF-8 as ANSI

That said, the support is still buggy at this point

  • Freeze issue in Windows 10 1803 when use UTF-8 as default code page
  • when unicode beta support in windows 10 is turned on, add-ons fail to install
  • UTF-8 support for single byte character sets is beta in Windows and likely breaks a lot of applications not expecting this
  • Build fail with internal error in MSVC

Update:

Microsoft has also added the ability for programs to use the UTF-8 locale without even setting the UTF-8 beta flag above. You can use the /execution-charset:utf-8 or /utf-8 options when compiling with MSVC or set the ActiveCodePage property in appxmanifest

You can also use UTF-8 locale in older Windows versions by linking with the appropriate C runtime

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. To enable UTF-8 mode, use «UTF-8» as the code page when using setlocale. For example, setlocale(LC_ALL, ".utf8") will use the current default Windows ANSI code page (ACP) for the locale and UTF-8 for the code page.

To use this feature on an OS prior to Windows 10, such as Windows 7, you must use app-local deployment or link statically using version 17134 of the Windows SDK or later. For Windows 10 operating systems prior to 17134, only static linking is supported.

UTF-8 Support

answered Jun 22, 2019 at 10:42

phuclv's user avatar

phuclvphuclv

26.7k15 gold badges115 silver badges235 bronze badges

From what I read about Microsoft AppLocale tool on Wikipedia, the tool can NOT change your code page to UTF-8. It only works with Non-Unicode applications, but UTF-8 is part of Unicode standard.

Under the hood, Unicode processing of non-ASCII characters greatly differs from non-Unicode one, so while it is possible to change between non-Unicode code pages (this is what AppLocale does) it is NOT possible to change between Unicode and non-Unicode without modification of the application made by its producer.

answered Jan 29, 2016 at 15:40

miroxlav's user avatar

miroxlavmiroxlav

13k6 gold badges65 silver badges103 bronze badges

2

Just to mention it here:
In Windows 10 17133 there is now a beta option to use UTF-8 for worldwide support. But it does not help with non-Unicode programs for me as of now, but it is placed on the pop-up where I can change the locale for non-Unicode programs.

So, maybe they are working on something to end the necessity of having to change the locale for non-Unicode programs.

hippietrail's user avatar

hippietrail

4,50515 gold badges53 silver badges86 bronze badges

answered Apr 11, 2018 at 13:54

anthropos's user avatar

3

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

R internally allows strings to be represented in the current native
encoding, in UTF-8 and in Latin 1. When interacting with the operating
system or external libraries, all these representations have to be converted
to native encoding. On Linux and macOS today this is not a problem, because
the native encoding is UTF-8, so all Unicode characters are supported. On
Windows, the native encoding cannot be UTF-8 nor any other that could
represent all Unicode characters.

Windows sometimes replaces characters by similarly looking representable
ones (“best-fit”), which often works well but sometimes has surprising
results, e.g. alpha character becomes letter a. In other cases, Windows
may substitute non-representable characters by question marks or other and R
may substitute by \uxxx, \UXXXXXXXX or other escapes. A number of
functions accessing the OS consequently have complicated semantics and
implementation on Windows. For example, normalizePath for a valid path
tries to return also a valid path, which is a path to the same file. In a
naive implementation, the normalized path could be non-existent or point to
a different file due to best-fit, even when the original path is perfectly
representable and valid.

This limitation of R on Windows is a source of pain for users who need to
work with characters not representable in their native encoding. R provides
“shortcuts” that sometimes bypass the conversion, e.g. when reading UTF-8
text files via readLines, but these work only for selected cases, when
external software is not involved and their use is difficult.

Finally, the latest Windows 10 allows to set UTF-8 as the native encoding. R
has been modified to allow this setting, which wasn’t hard as this has been
supported on Unix/macOS for years.

The bad news is that the UTF-8 support on Windows requires Universal C
Runtime (UCRT), a new C runtime. We need a new compiler toolchain and have
to rebuild all external libraries for R and packages: no object files built
using the older toolchains (Rtools 4 and older) can be re-used.

UCRT can be installed on older versions of Windows, but UTF-8 support will
only work on Windows 10 (November 2019 update) and newer.

The rest of this text explains in more detail what native UTF-8 support
would bring to Windows users of R. This text is simplifying out a number of
details in order to be accessible to R users who are not package developers.
An additional text for package developers and maintainers of infrastructures
to build R on Windows is provided
here,
with details on how to build R using different infrastructures and how to
build R with UCRT.

A demo binary installer for R and recommended packages is available (a link
appears later in this text) as well as a demo toolchain, which has a number
of libraries and headers for many but not all CRAN/BIOC packages.

Implications for RGui

RGui (RStudio is similar as it uses the same interface to R) is a
Windows-only application implemented using Windows API and UTF-16LE. In R
4.0 and earlier, RGui can already work with all Unicode characters.

RGui can print UTF-8 R strings. When running with RGui, R escapes UTF-8
strings and embeds them into strings otherwise in native encoding on output.
RGui understands this proprietary encoding and converts to UTF-16LE before
printing. This is intended to be used in all outputs R produces for RGui,
but the approach has its limits: it becomes complicated when formatting the
output and R does not know yet where it will be printed. Many corner cases
have been fixed, some recently, but likely some are remaining.

RGui can already pass Unicode strings to R. This is implemented by another
semi-proprietary embedding, RGui converts UTF-16LE strings to the native
encoding, but replaces the non-representable characters by \u and \U
escapes that are understood by the parser. The parser will then turn these
into R UTF-8 strings. This means that non-representable characters can be
used only where \u and \U escapes are allowed by R, which includes R
string literals where it is most important, but such characters cannot be
even in comments.

As a side note here, I believe that to keep international collaboration on
software development, all code should be in ASCII, definitely all symbols,
and I would say even in English, including comments. But still, R is used
also interactively and this is a technical limitation, not an intentionally
enforced requirement.

For example, one can paste these Czech characters into Rgui: ěščřžýáíé.
On Windows running in a English locale:

> x <- "ěščřžýáíé"
> Encoding(x)
[1] "UTF-8"
> x
[1] "ěščřžýáíé"

This works fine. But, a comment is already a problem:

> f <- function() {
+ x # ěščřžýáíé
+ }
> f
function() {
x # \u11bš\u10d\u159žýáíé
}

Some characters are fine, some are not.

In the experimental build of R, UTF-8 is the native encoding, so RGui will
not use any \u, \U escapes when sending text to R and R will not embed
any UTF-8 strings, because the native encoding is already UTF-8. The
example above then works fine:

> f <- function() {
+ x # ěščřžýáíé
+ }
> f
function() {
x # ěščřžýáíé
}

UTF-8 is selected automatically as the encoding for the current locale in
the experimental build:

> Sys.getlocale()
[1] "LC_COLLATE=English_United States.utf8;LC_CTYPE=English_United States.utf8;LC_MONETARY=English_United States.utf8;LC_NUMERIC=C;LC_TIME=English_United States.utf8"
> 

Note that RGui still needs to use fonts that can correctly represent the
characters. Similarly, not all fonts are expected to correctly display
examples in this text.

Implications for RTerm

RTerm is a Windows application not using Unicode, like most of R it is
implemented using the standard C library assuming that the encoding-specific
operations will work according to the C locale. In R 4.0 and earlier, RTerm
cannot handle non-representable characters.

We cannot even paste non-representable characters to R. They will be
converted automatically to the native encoding. Pasting “ěščřžýáíé” results
in

> escrzyáíé

For the Czech text on Windows running in English locale, this is not so bad
(only some diacritics marks are removed), but still not the exact
representation. For Asian languages on Windows running in English locale,
the result is unusable.

In principle, we can use the \u and \U sequences manually to input
strings, but they still cannot be printed correctly:

> x <- "\u11b\u161\u10d\u159\u17e\u0fd\u0e1\u0ed\u0e9"
> Encoding(x)
[1] "UTF-8"
> x
[1] "escrzyáíé"
> as.hexmode(utf8ToInt(x))
[1] "11b" "161" "10d" "159" "17e" "0fd" "0e1" "0ed" "0e9"

The output shows that the string is correct inside R, it just cannot be printed
on RTerm.

In the experimental build of R, if we run cmd.exe and then change the code
page to UTF-8 via “chcp 65001” before running RTerm, this works as it should

> x <- "ěščřžýáíé"
> x
[1] "ěščřžýáíé"
> x <- "ěščřžýáíé"
> Encoding(x)
[1] "UTF-8"
> x
[1] "ěščřžýáíé"

This text is not going into details about where the characters exactly get
converted/best-fitted, but the key thing is that with the UTF-8 build and
when running cmd.exe in the UTF-8 code page (65001), without any
modification of RTerm code, RTerm works with Unicode characters.

As with RGui, the terminal also needs apropriate fonts.. The same example
with a Japanese text: こんにちは, 今日は

> x <- "こんにちは, 今日は"
> Encoding(x)
[1] "UTF-8"
> x
[1] "こんにちは, 今日は"

This example works fine with the experimental build on my system, but with
the default font (Consolas), the characters are replaced by a question mark
in a square. Still, just switching to another font, e.g. FangSong, in the
cmd.exe menu, the characters appear correct in already printed text. The
characters will also be correct when one pastes them to an application that
uses the right font.

Implications for interaction with the OS

R on Windows already uses the Windows API in many cases instead of the
standard C library to avoid the conversion or to get access to
Windows-specific functionality. More specifically, R tries to always do it
when passing strings to the OS, e.g. creating a file with a
non-representable name already works. R converts UTF-8 strings to UTF16-LE,
which Windows understands. However, R packages or external libraries often
would not have such Windows specific code and would not be able to do that.
With the experimental build, these problems disappear because the standard C
functions, which in turn usually call the non-unicode Windows API, will use
UTF-8.

A different situation is when getting strings from the operating system, for
example listing files in a directory. R on Windows in such cases uses the
C, non-unicode API or converts to the native encoding, unless this is a
direct transformation of inputs that are already UTF-8. Please see R
documentation for details; this text provides a simplification of the
technical details.

In principle, R could also have used Windows-specific UTF-16LE calls and
convert the strings to UTF-8, which R can represent. It would not be that
much more work given how much effort has been spent on the functions passing
strings to Windows.

However, R has been careful not to introduce UTF-8 strings for things the
user has not already intentionally made UTF-8, because of problems that this
would cause for packages not handling encodings correctly. Such packages
will mysteriously start failing when incorrectly using strings in UTF-8 but
thinking they were in native encoding. Such problems will not be found by
automated testing, because tests don’t use such unusual inputs and are often
run in English or similar locales.

This precaution came at a price of increased complexity. For example, the
normalizePath implementation could be half the code size or less if we
allowed introducing UTF-8 strings. R instead normalizes “less”, e.g. does
not follow a symlink if it helps, but produces a representable path name for
one that is in native encoding.

With UTF-8 as the native encoding, these considerations are no longer
needed. Listing files in a directory when not-representable is no longer an
issue (when valid Unicode) and it works in the experimental build without
any code change.

Another issue is with external libraries that already started solving this
problem their way, long before Windows 10. Some libraries bypass any
external code and the C library for strings and perform string operations in
UTF-8 or UTF-16LE, sometimes with the help of external libraries, typically
ICU.

When R interacts with such libraries, it needs to know which encoding those
libraries expect, and that sometimes changes from native encoding to UTF-8
as the libraries evolve. For example, Cairo switched to UTF-8, so R had to
notice, and had to convert strings for newer Cairo versions to UTF-8 but for
older versions to native encoding.

Such change is sometimes hard to notice, because the type remains the same,
char *. Also handling these situations increases code complexity. One
has to read carefully the change logs for external libraries, otherwise
running into bugs that are hard to debug and almost impossible to detect by
tests, as they don’t use unusual characters. Such transitions of external
libraries will no longer be an issue with UTF-8 being the native encoding.

Implications for internal functionality

R allows multiple encoding of strings in R character objects, with a flag
whether it is UTF-8, Latin 1 or native. But, eventually strings have to be
converted to char * when interacting with the C library, the operating
system and other external libraries, or with external code incorporated into
R.

Historically, the assumption was that once typed char *, the strings are
always in one encoding, and then it needs to be the native encoding. This
makes a lot of sense as otherwise maintaining the code becomes difficult,
but R made a number of exceptions e.g. for the shortcut in readLines, and
sometimes it helps to keep strings longer as R character objects. Still,
sometimes the conversion to native encoding is done just to have a char *
representation of the string, even though not yet interacting with
C/external code. All these conversions disappear when UTF-8 becomes the
native encoding.

One related example is R symbols. They need to have a unique representation
defined by a pointer stored in the R symbol table. For any effective
implementation, they need to be in the same encoding, which now is the
native encoding. A logical improvement would be converting to UTF-8,
instead, but that would have potentially non-trivial performance overhead.
These concerns are no longer necessary when UTF-8 becomes the native
encoding.

In R 4.0, this limitation has as undesirable impact on hash maps:

e <- new.env(hash=TRUE)
assign("a", "letter a", envir=e)
assign("\u3b1", "letter alpha", envir=e)
ls(e)

On Windows, this produces a hash map with just a single element named “a”,
because \u3b1 (α) gets best-fitted by Windows to letter “a”. With the
experimental build, this works fine as it does on Unix/macOS, adding two
elements to the hash map. Even though using non-ASCII variable names is
probably not the right thing to do, a hash map really should be able to
support arbitrary Unicode keys.

Demo

The experimental build of R can be downloaded from
here. It has
base and recommended packages, but will not work with other packages that
use native code. The experimental toolchain allows to test more packages
(but not all CRAN/BIOC), more information is available
here
and may be updated without notice (there is always SVN history of it). Not
for production use.

Содержание

  • Способ 1: Изменение системного языка
  • Способ 2: Изменение параметра использования бета-версии Юникода
  • Способ 3: Редактирование реестра
  • Способ 4: Замена системного файла
  • Способ 5: Проверка целостности системных файлов
  • Способ 6: Возвращение Windows к заводским настройкам
  • Исправление кодировки в содержании и названиях файлов
  • Вопросы и ответы

Кракозябры вместо русских букв в Windows 11

Способ 1: Изменение системного языка

Чаще всего проблемы с отображением русских букв в Windows 11 связаны с некорректно установленными языковыми параметрами. Подобные дефекты могут появиться как при переименовании файлов, так и в интерфейсах сторонних программ или даже в некоторых частях операционной системы. Соответственно, понадобится проверить вручную языковые настройки и установить нужные, обеспечив тем самым поддержку текстовой кодировки. Универсальную инструкцию по этой теме вы найдете в другой статье на нашем сайте, перейдя по следующей ссылке.

Подробнее: Смена языка интерфейса ОС Windows 11

Кракозябры вместо русских букв в Windows 11-01

Способ 2: Изменение параметра использования бета-версии Юникода

Юникод (UTF-8) — стандартное кодирование текста для поддержки многих языков. В Windows 11 предлагается использовать его вместо основных языковых кодировок для каждого отдельного региона. Пользователь может столкнуться с отображением «кракозябр» вместо русских букв как при использовании функции, так и когда она отключена. Поэтому понадобится изменить состояние настройки и переключить кодировку. Для этого достаточно следовать предложенной ниже инструкции.

  1. Откройте «Пуск» и перейдите в «Параметры», кликнув по значку с изображением шестеренки.
  2. Кракозябры вместо русских букв в Windows 11-02

  3. В новом окне на панели слева выберите раздел «Время и язык», затем щелкните по категории «Язык и регион», чтобы перейти к ней.
  4. Кракозябры вместо русских букв в Windows 11-03

  5. Нажмите по ссылке «Административные языковые параметры».
  6. Кракозябры вместо русских букв в Windows 11-04

  7. Отобразится дополнительное окно с названием «Регион», в котором следует выбрать вкладку «Дополнительно» и кликнуть по кнопке «Изменить язык системы».
  8. Кракозябры вместо русских букв в Windows 11-05

  9. Поставьте или снимите галочку около пункта «Бета-версия: Использовать Юникод (UTF-8) для поддержки языка во всем мире» в зависимости от того, активна ли она сейчас. Сохраните изменения и отправьте ПК на перезагрузку.
  10. Кракозябры вместо русских букв в Windows 11-06

Способ 3: Редактирование реестра

Метод с редактированием реестра несет определенные риски, поскольку будут изменены системные параметры, отвечающие за корректность работы графического интерфейса. Поэтому рекомендуем перед вмешательством обязательно сделать резервную копию и разобраться с тем, как восстановить изначальное состояние реестра, если после применения новых настроек возникнут проблемы с работой ОС.

Подробнее: Восстановление системного реестра Windows 11

После всех подготовительных действий можно переходить непосредственно к настройке реестра. Этот процесс подразумевает проверку текущего языкового параметра с его редактированием или заменой, если это будет необходимо. Внимательно следуйте руководству, чтобы ни на каком из этапов не возникло трудностей.

  1. Откройте «Пуск», через поиск отыщите «Редактор реестра» и запустите данное приложение.
  2. Кракозябры вместо русских букв в Windows 11-07

  3. В его адресную строку вставьте путь Компьютер\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls и перейдите по нему.
  4. Кракозябры вместо русских букв в Windows 11-08

  5. На панели слева выберите каталог с названием «CodePage» и внизу списка с параметрами отыщите «ACP». Вам необходимо убедиться в том, что данная настройка имеет значение 1251.
  6. Кракозябры вместо русских букв в Windows 11-09

  7. Если это не так, щелкните по параметру дважды и внесите изменение. По завершении обязательно перезагрузите ПК и проверьте, удалось ли такой настройкой исправить «кракозябры».
  8. Кракозябры вместо русских букв в Windows 11-010

  9. В случае сохранения ошибки понадобится осуществить подмену файла. Для этого найдите в этой же папке параметры «1251» и «1252». Если каждый из них существует, то «1251» удалите.
  10. Кракозябры вместо русских букв в Windows 11-011

  11. Для «1252» поменяйте значение на c_1251.nls, сохраните изменения и снова перезагрузите компьютер.
  12. Кракозябры вместо русских букв в Windows 11-012

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

Способ 4: Замена системного файла

Следующий метод тоже подразумевает изменение системных настроек. При помощи замены файлов можно добиться исправления кодировки, когда язык операционной системы по каким-то причинам распознается некорректно и появляются «кракозябры» вместо нормальных букв. Будьте готовы к тому, что такие изменения тоже могут негативно сказаться на работе ОС, поэтому во время выполнения инструкции соблюдайте все рекомендации по сохранению оригиналов файлов, чтобы в случае чего восстановить все так, как это было ранее.

  1. Откройте «Проводник» и перейдите по пути C:/Windows/System32.
  2. Кракозябры вместо русских букв в Windows 11-013

  3. В данном каталоге отыщите файл с названием «C_1252.NLS».
  4. Кракозябры вместо русских букв в Windows 11-014

  5. Для него нужно изменить владельца, чтобы система разрешила переименование и выполнение других действий. Щелкните по файлу правой кнопкой мыши и из контекстного меню выберите пункт «Свойства».
  6. Кракозябры вместо русских букв в Windows 11-015

  7. Перейдите на вкладку «Безопасность» и нажмите по «Дополнительно».
  8. Кракозябры вместо русских букв в Windows 11-016

  9. В новом окне вы увидите текущего владельца файла, коим наверняка будете не вы. Для исправления этой ситуации кликните по «Изменить».
  10. Кракозябры вместо русских букв в Windows 11-017

  11. Можете ввести имя объекта вручную, но в большинстве случаев у пользователя нет информации о том, как точно называется его учетная запись. Поэтому лучше пойти простым путем автоматического поиска, сначала нажав по «Дополнительно».
  12. Кракозябры вместо русских букв в Windows 11-018

  13. В следующем окне нажмите кнопку «Поиск».
  14. Кракозябры вместо русских букв в Windows 11-019

  15. Дождитесь загрузки учетных записей и выберите среди них свою. Подтвердите внесение изменений и закройте данное окно.
  16. Кракозябры вместо русских букв в Windows 11-020

  17. Остается только добавить полные права доступа к файлу для нового владельца. В окне «Свойств» на вкладке «Безопасность» нажмите по «Изменить».
  18. Кракозябры вместо русских букв в Windows 11-021

  19. В списке «Группы или пользователи» выберите свою учетную запись, предоставьте полные права и сохраните изменения.
  20. Кракозябры вместо русских букв в Windows 11-022

  21. Теперь вам нужно переименовать файл «C_1252.NLS». Лучшим вариантом будет изменить его формат, допустим, на текстовый. Если что-то пойдет не так, его всегда можно вернуть к NLS.
  22. Кракозябры вместо русских букв в Windows 11-023

  23. Далее в этой же папке отыщите файл «C_1251.NLS» и создайте его копию на рабочем столе.
  24. Кракозябры вместо русских букв в Windows 11-024

  25. Для данного файла с названием «C_1251.NLS» установите новое, переименовав его на «C_1252.NLS». Если действие недоступно, измените владельца и для этого файла точно так же, как это было показано выше.
  26. Кракозябры вместо русских букв в Windows 11-025

При помощи нехитрых манипуляций вы произвели замену файлов, отвечающих за локализацию в Windows 11. «C_1252.NLS» нужен для нормального отображения английского языка системы, который является основным. При помощи замены мы сделали так, чтобы основным теперь считался русский и кодировка была исправлена в тех местах, где наблюдаются проблемы с отображением букв. Если после перезагрузки компьютера выяснилось, что система функционирует хуже, появились ошибки и сама проблема не была исправлена, верните оригинальные файлы в ту же папку и снова перезагрузите ПК.

Способ 5: Проверка целостности системных файлов

Не стоит исключать тот факт, что появление «кракозябр» вместо нормального отображения букв иногда свидетельствует о том, что в системе нарушена целостность файлов, отвечающих за локализацию или работу с определенными текстовыми кодировками. Самостоятельно проверить вы это не сможете, поэтому доверьте операцию автоматизированным средствам, а именно специальным консольным утилитам. Информацию об их применении вы найдете в материале от другого нашего автора по ссылке ниже.

Подробнее: Использование и восстановление проверки целостности системных файлов в Windows

Кракозябры вместо русских букв в Windows 11-026

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

Подробнее: Сброс Windows 11 к заводским настройкам

Кракозябры вместо русских букв в Windows 11-027

Исправление кодировки в содержании и названиях файлов

В некоторых случаях пользователь сталкивается с тем, что «кракозябры» отображаются только в названиях конкретных текстовых файлов или после их открытия через текстовые редакторы, когда речь идет о просмотре содержимого. В первую очередь можем порекомендовать сменить текстовый редактор, поскольку не все поддерживают разные кодировки, особенно если речь идет о стандартном «Блокноте». Если это не принесло должного результата, можно попробовать восстановить кодировку через разные онлайн-сервисы. Они поддерживают как загрузку файлов целиком, так и вставку содержимого из буфера обмена.

Подробнее: Исправление кодировки при помощи онлайн-сервисов

Кракозябры вместо русских букв в Windows 11-028

  • Windows 8 start menu 8 download
  • Windows 8 touch civilization 5 что это
  • Windows 8 rtm скачать торрент
  • Windows 8 rtm coresinglelanguage oem dm скачать
  • Windows 8 release preview russian