I have a length-1 character vector x, and I want to replace ' in the
character into ''. What I do now is to iconv x into suitable current
Encoding, then use gsub. It works well if I knows what x is (e.g.
Chinese charater), as I can use suitable locales to handle it.

### it works
x<- "some chinese character with ' in it"
Encoding(x) <- "UTF-8"
Sys.setlocale(,"CHS")
gsub("'","''",x)
##

It would be great if I can achieve the same effect without the
suitable locales setting (e.g. even the Sys.setlocale(,"English")
instead of Sys.setlocale(,"CHS")). Is it possible? Thanks.

-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to