Mark
Mark

Reputation: 10984

Show an ASCII character

I want to show a block ASCII character █ (it's ASCII code is 219),

How can I show it in terminal?

I am using RGui on WinXP

Upvotes: 4

Views: 3386

Answers (3)

Karsten W.
Karsten W.

Reputation: 18500

This works on Windows

> "\u2588"
[1] "█"

Upvotes: 1

Jyotirmoy Bhattacharya
Jyotirmoy Bhattacharya

Reputation: 9587

Following mobrule, the following works on R running in a UTF-8 locale on Linux:

> "\u258A"
[1] "▊"

Upvotes: 4

mob
mob

Reputation: 118665

You can use backslash to escape otherwise unprintable characters:

print("\245")

displays the Yen character (¥) on my gui. The 245 is in octal format, so the above expression is printing out ASCII (or whatever encoding the GUI is using) character 165.

219 is 333 in octal, but

print("\333")

prints out the Û character on my gui.


A few (but by no means all) unicode characters are also supported on the R gui:

cyrillic_d <- "\u0414"
print(cyrillic_d)

outputs Д.

Upvotes: 5

Related Questions