senza
senza

Reputation: 21

Working with Unicode in R

I read in text from a MySQL table into and R dataframe. (using RODBC, sqlFetch). Have two questions:

  1. How do I figure out if R has read it in as utf-8? It's character type but what's the function to show encoding?
  2. How do I compute the number of characters in an Unicode string in R?

The length function does not work with Unicode and always returns 1 I think.

Upvotes: 2

Views: 1488

Answers (1)

IRTFM
IRTFM

Reputation: 263301

You should be able to read the encoding (assuming it is specified) with:

Encoding(x)

The number of characters can be determined with:

nchar(x)

Upvotes: 3

Related Questions