The R Project SVN R

Rev

Rev 73509 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 73509 Rev 73510
Line 40... Line 40...
40
## check the example:
40
## check the example:
41
xx <- surrogate_pair(0x10437)
41
xx <- surrogate_pair(0x10437)
42
sprintf("%X", xx)
42
sprintf("%X", xx)
43
stopifnot(xx == c(0xD801, 0xDC37))
43
stopifnot(xx == c(0xD801, 0xDC37))
44
 
44
 
45
## there are 2^20 surrogate pairs, so check a random subset
45
## there are 2^20 surrogate pairs, but fast enough to check them all
46
set.seed(1)
-
 
47
x <- 0x10000 + sort(trunc(0x100000 * runif(1e5)))
46
x <- 0x10000:0x10FFFF
48
x1 <- intToUtf8(x)
47
x1 <- intToUtf8(x)
49
x2 <- utf8ToInt(x1)
48
x2 <- utf8ToInt(x1)
50
stopifnot(x2 == x)
49
stopifnot(x2 == x)
51
 
50
 
52
z <- surrogate_pair(x)
51
z <- surrogate_pair(x)