convert utf8 code point strings like to utf8

后端 未结 2 652
感情败类
感情败类 2020-12-18 12:28

I have a text file which contains some kind of fallback conversions of Unicode characters (the Unicode code points in angle brackets). So it contains e.g. foo

2条回答
  •  不思量自难忘°
    2020-12-18 12:44

    Perhaps:

    library(stringi)
    library(magrittr)
    
    "foobar and cray" %>% 
      stri_replace_all_regex("", "\\\\u$1") %>% 
      stri_unescape_unicode() %>% 
      stri_enc_toutf8()
    ## [1] "foošbar and cražy"
    

    may work (I don't need the last conversion on macOS but you may on Windows).

提交回复
热议问题