我想从语法上从RStudio删除无法识别(未解码)的字符。使用iconv
函数无法正常工作。如何解决下图所示的问题?
RStudio在我的编辑器中无法识别的文本:
这是无法在RStudio pp.10-11)Pub中解码的文本
上面的代码:
text <- readClipboard()
rstudioapi::insertText(text) # Insert the text to the editor
# This is how it looks like
"This is a text that cannot be decoded in RStudio: pp. 10–11: "
# If I change the encoding:
text <- iconv(text, "UTF-8", "UTF-8", sub='')
# Output that I get is without "–" as well:
rstudioapi::insertText(text)
"This is a text that cannot be decoded in RStudio: pp.1011: " # Output without "-"
# This is what I want is just to remove dot with pink character:
rstudioapi::insertText(text)
"This is a text that cannot be decoded in RStudio: pp.10–11: "