Bug 16732 - Unicode characters are garbled when printing function
Summary: Unicode characters are garbled when printing function
Alias: None
Product: R
Classification: Unclassified
Component: Windows GUI / Window specific (show other bugs)
Version: R 3.2.3
Hardware: x86_64/x64/amd64 (64-bit) Windows 64-bit
: P5 minor
Assignee: R-core
Depends on:
Reported: 2016-02-27 10:48 UTC by Michio Oguro
Modified: 2017-05-25 12:00 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Michio Oguro 2016-02-27 10:48:15 UTC
In windows version of Rgui, Unicode characters (I tested using Japanese) in a function are garbled when printing the function in console.


# This can work
> print("日本語")
[1] "日本語"

# This makes garbled characters
> function(){"日本語"}
function() {'譌・譛ャ隱
Comment 1 Duncan Murdoch 2017-05-22 14:03:13 UTC
This is a response to your bug posting in Feb, 2016.

Would you be able to test your examples in a current version of R-devel?  When I run them on MacOS things are fine, and in Windows in a Latin1 locale, I get

> function(){"日本語"}

which I think is an acceptable result, because those escapes match the Japanese characters.  If I run that function it prints the result as 

[1] "日本語"

which is what you'd want.  However, you are probably running Windows in a different locale, so it would be helpful to see what results you get.
Comment 2 Michio Oguro 2017-05-25 12:00:50 UTC
Thank you for your reply.

I tried following code on R Under development (unstable) (2017-05-22 r72718) -- "Unsuffered Consequences" on Windows 10.
It still print garbled characters

> test = function(){"日本語"}
> test()
[1] "日本語"
> test

My locale information is as follow:

> Sys.getlocale()
[1] "LC_COLLATE=Japanese_Japan.932;LC_CTYPE=Japanese_Japan.932;LC_MONETARY=Japanese_Japan.932;LC_NUMERIC=C;LC_TIME=Japanese_Japan.932"

If you need other information on my system, please feel free to ask me.