UTF8 [🇷 for BE/BA]

posted by Helmut Homepage – Vienna, Austria, 2015-09-08 17:02 (3573 d 21:10 ago) – Posting: # 15386
Views: 7,800

Hi Yung-jin,

txt21<-"esto es español\n"

cat(txt21)

esto es espanol


❝ Ps. The display of Spanish looks like not exactly same as input text.


On my system (Win7 64bit, German locale, R 3.2.2, font in /etc/Rconsole: Lucida Console) it’s fine:

cat(txt21)
esto es español


As a last resort one can always fall back to Unicode (see his old document). Try:

utf8 <- "esto es espa\u00f1ol\n"
cat(utf8)
esto es español


Whether or not a character can be displayed depends on the locale, the chosen font (and even on its version). Try:

start <- 33
end   <- 62276
dec.code <- start:end
hex.code <- sprintf("\\u%s", format(as.hexmode(dec.code), width=4))
m <- gregexpr("\\\\u[0-9A-Fa-f]{4}", hex.code)
regmatches(hex.code, m) <- lapply(
  lapply(regmatches(hex.code, m), substr, 3, 7), function(x)
  intToUtf8(as.integer(as.hexmode(x)), multiple=TRUE))
noquote(hex.code[1:2000])


Combining characters should be avoided if ever possible since they are available only in more recent versions of fonts. Try:

med.symbol <- "x\u0303\n"
cat(med.symbol)

Whiches gives a pretty on Vista+, but x~ on ≤XP…

Dif-tor heh smusma 🖖🏼 Довге життя Україна! [image]
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes

Complete thread:

UA Flag
Activity
 Admin contact
23,424 posts in 4,927 threads, 1,673 registered users;
49 visitors (0 registered, 49 guests [including 10 identified bots]).
Forum time: 14:13 CEST (Europe/Vienna)

Medical researches can be divided into two sorts:
those who think that meta is better and those
who believe that pooling is fooling.    Stephen Senn

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5