From mwtoews at sfu.ca  Mon May 26 01:15:12 2008
From: mwtoews at sfu.ca (mwtoews at sfu.ca)
Date: Mon, 26 May 2008 01:15:12 +0200 (CEST)
Subject: [Rd] Using unicode with sprintf or paste in Windows (PR#11515)
Message-ID: <20080525231512.573B0282EF48@mail.pubhealth.ku.dk>

Full_Name: Michael Toews
Version: 2.7.0
OS: Windows XP SP2
Submission from: (NULL) (24.80.163.230)


Using Unicode characters in Windows works with static strings (as of R 2.7.0),
however fails when used with sprintf() or paste(). For example, on R 2.7.0 for
Windows XP (SP2):

Static string (works, showing Greek Delta character):
> print("\u0394Q = 2.2 L/s")
[1] "&#916;Q = 2.2 L/s"

However, when I use paste() or sprintf(), the Unicodeness is lost:
> paste("\u0394Q =",round(1.2345,3),"L/s")
[1] "<U+0394>Q = 1.234 L/s"
> sprintf("\u0394Q = %.3f L/s",1.2345)
[1] "<U+0394>Q = 1.234 L/s"


I have also tested this with R 2.7.0 for Linux, which yields the following:
> print("\u0394Q = 2.2 L/s")
[1] "&#916;Q = 2.2 L/s"
> paste("\u0394Q =",round(1.2345,3),"L/s")
[1] "&#916;Q = 1.234 L/s"
> sprintf("\u0394Q = %.3f L/s",1.2345)
[1] "&#916;Q = 1.234 L/s"

(Note: this was posted on R-help with no replies:
https://stat.ethz.ch/pipermail/r-help/2008-May/162815.html )



[Rd] Using unicode with sprintf or paste in Windows (PR#11515)
mwtoews at sfu.ca