UTF-8 changes#1154
Conversation
and replace encode_utf8($x) by Encode::decode("UTF-8",$x)
as the prior is not a proper conversion, and the documentation at
https://perldoc.perl.org/Encode#encode_utf8
state that it should not be used for data exchange.
In several places use Encode::encode() explicitly, instead of just encode()
after a use Encode qw(encode).
Replace binmode(STDOUT, ":utf8");
with binmode(STDOUT, ":encoding(UTF-8)");
as Perl 5.30 makes sysread and syswrite on ":utf8" filehandles fatal
(it was deprecated in 5.24).
See: https://perldoc.perl.org/perl5300delta#Previously-deprecated-sysread()/syswrite()-on-:utf8-handles-is-now-fatal
There was a problem hiding this comment.
This looks good. I am not able to do any extensive testing on this as my usage rarely deals with anything that will really stress test the utf8 encoding and decoding.
I noticed that there is one instance of encode_utf8 that you did not convert to the Encode::encode("UTF-8", ...) method, and this is in lib/WeBWorK/EquationCache.pm. It may be it is not needed there. Just pointing this out.
Also, both Encode::decode_utf8 and Encode::encode_utf8 are used in PGcore.pm in the PG code. binmode(STDOUT, ":utf8") is also used there. Do those need to be changed also?
I'll look into that one soon.
Ideally yes, practically - probably not now.
|
|
I didn't see that issue. |
That is The use is in From some research 2 years ago, the issues were related to the autoloading mechanisms used by See:
|
|
Yeah, that probably is fine. Furthermore, does anyone even use images for equations anymore? MathJax is so much better. |
|
Yeah, I am not saying to remove the code for that. I am just saying it is probably not used much, and as such, it is probably not a serious concern if utf8 encoding is proper (if that is even needed for equations in any case). I am betting that the instances in which students have trouble with the javascript working are becoming increasingly infrequent (at least in regards to MathJax). I have never had that happen for my students as far as I know. |
I have run into a few such cases. Often asking the student to use a different browser than their default browser will overcome the problem. A few cooperative students who disabled browser extensions/plugins and bothered to respond after trying that reported success with extensions/plugins disabled. (There are several types of plugins which block content or modify content in ways the the user's don't really understand, but have some feature they like.) I have never got a student to test enough and write back telling me which extension/plugin caused their problem. The students typically just want to do the homework and move on. |
Submitted answers can contain UTF-8 character (even if they are not suitable), and almost everything gets rendered inside a math element in the "submitted answers" column in the results table. When using images equation display mode without the UTF-8 encoding an error page would be displayed (see the details in openwebwork/pg#443 (comment)), as the MD5 hash used to create file names cannot process Unicode characters from the internal Perl encoding of strings. The patch was made to encode into UTF-8, and the the image fails to be generated as LaTeX can't actually make the image so also fails appear in the rendered image, but the tool-top text does work. Having something fail to appear on screen, is far better than there being a WeBWorK error page. |
encode_utf8($x)byEncode::encode("UTF-8",$x), anddecode_utf8($x)byEncode::decode("UTF-8",$x)as the prior is not a proper conversion, and the documentation at https://perldoc.perl.org/Encode#encode_utf8
state that it should not be used for data exchange.
Encode::encode()explicitly, instead of justencode()after ause Encode qw(encode).binmode(STDOUT, ":utf8");withbinmode(STDOUT, ":encoding(UTF-8)");as Perl 5.30 makes sysread and syswrite on ":utf8" filehandles fatal (it was deprecated in 5.24).See: https://perldoc.perl.org/perl5300delta#Previously-deprecated-sysread()/syswrite()-on-:utf8-handles-is-now-fatal
So far I have not thoroughly tested the changes.
Motivation: