Converting a \u escaped Unicode string to ASCII

后端 未结 7 893
感动是毒
感动是毒 2020-11-30 09:05

After reading all about iconv and Encoding, I am still confused.

I am scraping the source of a web page I have a string that looks like thi

7条回答
  •  渐次进展
    2020-11-30 09:42

    Use parse, but don't evaluate the results:

    x1 <- 'pretty\\u003D\\u003Ebig'
    x2 <- parse(text = paste0("'", x1, "'"))
    x3 <- x2[[1]]
    x3
    # [1] "pretty=>big"
    is.character(x3)
    # [1] TRUE
    length(x3)
    # [1] 1
    

提交回复
热议问题