我应该在在线课程中使用utf-8编码吗?

时间:2021-12-02 00:19:08

Hello this is my question:

大家好,这是我的问题:

I am currently working on an introductory course on R programming for people with zero background on programming (this is people studying biology, veterinary, medicine, economics, ...), so they tend to be not very tech savvy and to use Windows. After they download and open the R scripts that I prepared, they are going to find every now and then badly encoded characters (as the course is in spanish and has many accents). This happens because my scripts are made with UTF-8 encoding and is not supported by default in Windows.

我目前正在为没有编程背景的人(这是学习生物学、兽医、医学、经济学……的人)准备一门关于R编程的入门课程,所以他们往往不太懂技术,也不太会使用Windows。在他们下载并打开我准备的R脚本后,他们将会发现每一个现在,然后是糟糕的编码字符(因为这门课程是西班牙语,而且有很多口音)。这是因为我的脚本是用UTF-8编码编写的,在Windows中默认不支持。

The options to avoid this nuisance are:

避免这种麻烦的方法是:

  1. change all my scripts to the encoding WINDOWS-1252
  2. 将所有脚本修改为WINDOWS-1252编码
  3. instruct everyone to change their encoding to UTF-8
  4. 指导每个人将编码转换为UTF-8。

The first option is more annoying for me and helps prevents the students to be distracted with a quite minor detail.

第一个选项对我来说更烦人,它可以防止学生们因为一个很小的细节而分心。

The second option has no clear advantages from the pedagogic point of view, so I'd like to ask which virtues do you think it has...

从教育学的角度来看,第二种选择没有明显的优势,所以我想问一下你认为它有哪些优点……

Thanks in advance!

提前谢谢!

2 个解决方案

#1


2  

I would highly recommend instructing them to change their encoding to UTF-8. I've had the same issue on numerous occassions with web-app scripting and generally speaking it's alot more hassle to go through the code than to instruct the customer (or in your case, student) to use the UTF-8 encoding.

我强烈建议他们将编码改为UTF-8。在很多web应用程序脚本编写的情况下,我都遇到过同样的问题,一般来说,检查代码比指导客户(或者您的学生)使用UTF-8编码要麻烦得多。

Afterall the course you're holding is an introductionary course, you might want to consider briefly covering the topic and explain the differences between the two - and more specifically: What happens when it doesn't work?

既然你所修的课程是一门介绍性的课程,你或许应该考虑简单地介绍一下这个主题,并解释一下这两门课程之间的不同之处——更具体地说:当它不起作用时会发生什么?

You have a golden opportunity to save yourself some time later down road, and possibly avoid the "Why is there question marks all over my screen"-question altogether!

你有一个绝好的机会可以在以后的道路上节省你自己一些时间,并且有可能避免“为什么我的屏幕上到处都是问号”的问题。

#2


1  

Maybe you can avoid non-ASCII characters in your scripts. For example, to represent the greek "mu" character, you could use

也许您可以在脚本中避免非ascii字符。例如,要表示希腊“mu”字符,可以使用

> mu <- "\u03BC"
> Encoding(mu) <- "UTF-8"
> mu
[1] "μ"

Now if you print mu on the console, it is displayed correctly. In the script, you did not use any non-ASCII character at all.

现在如果您在控制台打印mu,它将被正确显示。在脚本中,您根本没有使用任何非ascii字符。

#1


2  

I would highly recommend instructing them to change their encoding to UTF-8. I've had the same issue on numerous occassions with web-app scripting and generally speaking it's alot more hassle to go through the code than to instruct the customer (or in your case, student) to use the UTF-8 encoding.

我强烈建议他们将编码改为UTF-8。在很多web应用程序脚本编写的情况下,我都遇到过同样的问题,一般来说,检查代码比指导客户(或者您的学生)使用UTF-8编码要麻烦得多。

Afterall the course you're holding is an introductionary course, you might want to consider briefly covering the topic and explain the differences between the two - and more specifically: What happens when it doesn't work?

既然你所修的课程是一门介绍性的课程,你或许应该考虑简单地介绍一下这个主题,并解释一下这两门课程之间的不同之处——更具体地说:当它不起作用时会发生什么?

You have a golden opportunity to save yourself some time later down road, and possibly avoid the "Why is there question marks all over my screen"-question altogether!

你有一个绝好的机会可以在以后的道路上节省你自己一些时间,并且有可能避免“为什么我的屏幕上到处都是问号”的问题。

#2


1  

Maybe you can avoid non-ASCII characters in your scripts. For example, to represent the greek "mu" character, you could use

也许您可以在脚本中避免非ascii字符。例如,要表示希腊“mu”字符,可以使用

> mu <- "\u03BC"
> Encoding(mu) <- "UTF-8"
> mu
[1] "μ"

Now if you print mu on the console, it is displayed correctly. In the script, you did not use any non-ASCII character at all.

现在如果您在控制台打印mu,它将被正确显示。在脚本中,您根本没有使用任何非ascii字符。