Skip to content

Windows 11: Console corrupts UTF-8 input after pressing Enter until Sys.setlocale() is called #18139

Description

@mplt58

System

  • RStudio: 2026.06.0+242 (Blue Plumbago)
  • R: 4.6.1 (2026-06-24) UCRT
  • Windows 11 Build 26200
  • Locale: Turkish_Türkiye.utf8
  • UTF-8: TRUE
  • Code page: 65001

Problem

Immediately after starting RStudio, typing Turkish characters directly into the Console works while typing, but after pressing Enter the echoed text becomes corrupted.

Example:

"Çalışma"

After calling:

Sys.setlocale("LC_CTYPE", Sys.getlocale("LC_CTYPE"))

the problem immediately disappears, although Sys.getlocale() reports exactly the same value before and after the call.

What works

  • RGui works correctly.
  • Source editor works correctly.
  • Running code from the source editor (Ctrl+Enter) works correctly.
  • print() output is correct.
  • charToRaw() confirms the string is valid UTF-8.

What does not work

Only interactive Console input is affected.

Reproduction

  1. Start RStudio.
  2. In the Console type:

"Çalışma"

  1. Press Enter.

The Console corrupts the echoed UTF-8 text.

Then run:

Sys.setlocale("LC_CTYPE", Sys.getlocale("LC_CTYPE"))

Repeat the same command and the problem disappears immediately.

Additional symptom

Another symptom is that immediately after starting RStudio, the Console behaves incorrectly before calling Sys.setlocale().

For example:

list.files()

returns

character(0)

even though there are files in the current working directory.

After executing:

Sys.setlocale("LC_CTYPE", Sys.getlocale("LC_CTYPE"))

(or my fix_tr() helper which calls Sys.setlocale()),

the same command:

list.files()

immediately returns the correct list of files.

So calling Sys.setlocale() appears to refresh more than just UTF-8 handling in the Console.

Additional information

  • Clearing all RStudio cache/state directories did not permanently fix the issue.
  • The issue also occurs with a fresh Windows user profile.

Activity

  1. kevinushey commented on Jul 3, 2026

    @kevinushey
    Collaborator

    Thanks for the bug report. Did this problem occur in the previous release of RStudio? Installers are available here: https://docs.posit.co/supported-versions/rstudio.html

  2. self-assigned this
    on Jul 3, 2026
  3. kevinushey commented on Jul 4, 2026

    @kevinushey
    Collaborator

    Thanks again for the detailed report. We suspect this is related to the locale name containing a non-ASCII character -- Windows 11 renamed Turkey to Türkiye, so the default Turkish locale is now Turkish_Türkiye.utf8 -- similar to what we've seen with Norwegian Bokmål_Norway.utf8 in #15008. To help us pin down exactly which conversion is failing, could you share some diagnostics from a fresh RStudio session, before calling Sys.setlocale() or any workaround? (If your .Rprofile runs fix_tr() or similar, please disable that temporarily first.)

    1. The output of:

      Sys.getlocale()
      l10n_info()
      Sys.getenv(c("LC_ALL", "LC_CTYPE", "LANG"))
    2. Type "Çalışma" into the Console, press Enter, and paste exactly what the corrupted text looks like (e.g. Çalışma-style mojibake, \u-style escapes, ? characters, ...). The shape of the corruption tells us which direction of conversion is failing.

    3. Still before any workaround, the output of:

      charToRaw("Çalışma")
    4. Is the Windows option "Beta: Use Unicode UTF-8 for worldwide language support" enabled on your system? (Settings > Time & Language > Language & Region > Administrative language settings > Change system locale...)

    5. For the list.files() symptom: do the file names (or the path of the working directory) contain Turkish characters? And does list.files() print any warnings along with character(0)?

    And if you have a chance to try the previous RStudio release as mentioned above, that would still be very helpful in determining whether this is a regression.

  4. mplt58 commented on Jul 4, 2026

    @mplt58
    Author

    Hi Kevin,
    thank you for your interest.

    Here are the diagnostics from a fresh RStudio session before applying any workarounds:

    1. Locale & Environment Outputs

    Sys.getlocale()
    [1] "C"

    l10n_info()
    $MBCS
    [1] TRUE

    $UTF-8
    [1] TRUE

    $Latin-1
    [1] FALSE

    $codepage
    [1] 65001

    $system.codepage
    [1] 65001

    Sys.getenv(c("LC_ALL", "LC_CTYPE", "LANG"))
    LC_ALL LC_CTYPE LANG
    "" "" ""
    2.. Console Corruption Behavior
    When typing "Çalışma" into the Console and pressing Enter, it results in a syntax error with corrupted escape characters:
    Çalışma
    Error: unexpected '\' in "al"

    1. Answers to your additional questions:
      Question 4 (Beta: Use Unicode UTF-8...): Yes, this option is enabled on my Windows system.

    Question 5 (list.files() symptom): Yes, the file names (and the path of the working directory) do contain Turkish characters.

    Thank you.

    Muhsin

  5. added theissue type on Jul 6, 2026
  6. mplt58 commented on Jul 7, 2026

    @mplt58
    Author

    Hi Kevin,
    I have tested the latest daily build which includes your fix for #18141 (commit b7a69bd), but unfortunately, the issue persists in a fresh session.
    As soon as I start RStudio:
    Sys.getlocale() still returns "C".
    Console displays corrupted Turkish characters.
    I noticed your note in the PR mentions that the fix might not fully resolve the startup-time corruption and that you might need a "Windows repro." Please let me know what specific logs or additional diagnostics you would like me to provide to help you investigate the root cause of this startup behavior.
    Best regards.

  7. kevinushey commented on Jul 7, 2026

    @kevinushey
    Collaborator

    Doh -- thanks for testing. One thing that would be useful to know: does adding a call to

    Sys.setlocale("LC_ALL", "")

    to your ~/.Rprofile make any difference? (Or, running that by hand in your R console?)

  8. mplt58 commented on Jul 7, 2026

    @mplt58
    Author

    Hi Kevin,
    Thank you for the suggestion. I tested running Sys.setlocale("LC_ALL", "") manually in the console, and it initially resolves the issue.
    After running the command, Turkish characters are parsed correctly (returning an "object not found" error instead of the previous syntax error caused by character corruption):

    Sys.setlocale("LC_ALL", "")
    [1] "LC_COLLATE=Turkish_Türkiye.utf8;LC_CTYPE=Turkish_Türkiye.utf8;LC_MONETARY=Turkish_Türkiye.utf8;LC_NUMERIC=C;LC_TIME=Turkish_Türkiye.utf8"

    çalışma
    Error: object 'çalışma' not found

    However, the fix is temporary. After running View(x) to open the Data Viewer, the session reverts back to the corrupted state, and Sys.getlocale() returns "C" again:

    View(df)
    Sys.getlocale()
    [1] "C"
    It seems like interacting with the Data Viewer/Object Explorer triggers the same locale-clobbering behavior you described in your technical notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions