绘图工具提示显示 unicode 字符而不是闪亮服务器中的字母(R

发布于 2025-01-13 17:01:05 字数 829 浏览 2 评论 0 原文

我有一个闪亮的应用程序在闪亮的服务器上运行,今天开始为所有重音字符提供错误(直到昨天晚上它都没有错误)。

我意识到所有文件似乎都是使用 utf-8 以外的其他类型的编码来获取的。因此,我尝试使用 source('file.R',encoding='utf-8') 强制它,但这会出现错误并且应用程序无法运行。

由于我找不到发生这种情况的原因,因此我将所有字符更改为其 unicode 格式 (\u00xx),并在需要时使用 enc2utf8

完成此操作后,大部分应用程序似乎都运行良好。我现在遇到的唯一问题是我的绘图图表的工具提示开始显示 unicode 值而不是字符,如下图所示。我尝试不在这些数据帧上使用 enc2utf8 ,但它也显示了有错误的字符。例如,它应该是 Último,但在不使用 enc2utf8 时,它会显示 <9a>ltimo

输入图片此处描述

我该如何解决这个问题?有没有更好的方法来强制以 utf-8 读取文件,而不是读取正在读取的任何编码?

额外信息:

  • 在 RStudio 中,我默认将所有文件保存为 UTF-8,因此我认为编码不应该成为问题。
  • 在我的本地计算机(Windows)中,应用程序运行良好,并且绘图完美显示。该错误仅发生在Linux机器上运行的服务器上

I have a shiny application running in a shiny server that started giving errors for all accented characters today (it was working with no errors until yesterday night).

I realized that all files seemed to be sourced using other types of encoding than utf-8. Thus, I tried forcing it using source('file.R', encoding='utf-8') , but this gives an error and the application doesn't run.

Since I could not find the reason to why this was happening, I changed all characters to their unicode format (\u00xx) and used the enc2utf8 where needed.

After doing this, most of the application seemed to be working fine. The only problem that I am having now, is that the tooltip of my plotly charts started showing the unicode value instead of the character as shown in the image below. I tried not using the enc2utf8 on those dataframes but it also showed the characters with errors. For example, it should be Último but it appears <c3><9a>ltimo when not using the enc2utf8.

enter image description here

How do I solve this problem? Is there a better way to force the files to be read in utf-8 instead of wharever encoding it is being read?

Extra information:

  • In RStudio I am saving all files as UTF-8 by default, so I assumed the encoding should not be an issue
  • In my local machine (windows) the application runs just fine and the plots are shown perfectly. The errors only occur on the server that runs in a linux machine

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文