Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
3b696b4
Add UTF8 to xmlrpc
goehle Jun 21, 2016
d2d636c
Add utf8 encoding to the base64 methods.
goehle Jul 15, 2016
539406c
picked an ascii character for the verb escape character so that it do…
goehle Aug 17, 2016
ed11055
Merge branch 'locbugs' of https://github.com/goehle/pg into develop
mgage Jul 30, 2017
a561c0e
Add additional utf8 related changes to PG files.
mgage Jul 31, 2017
414b356
Added functions SET_PROBLEM_LANGUAGE() SET_PROBLEM_TEXTDIRECTION() which
May 9, 2018
67fcefc
Added SET_PROBLEM_LANGUAGE() SET_PROBLEM_TEXTDIRECTION() functions which
May 9, 2018
a20a843
Merge branch 'develop_international' into develop_utf8_ver2
mgage Jul 23, 2018
b19e682
Merge pull request #319 from mgage/develop_utf8_ver2
mgage Jul 23, 2018
b947aa8
Merge pull request #356 from taniwallach/Add_lang_and_direction_to_PG…
mgage Jul 23, 2018
0733cad
Merge branch 'develop_international' into develop
mgage Oct 21, 2018
c8d0c3c
Replace "<:encoding(utf8)" by "<::utf8" this may be due to an obsol…
mgage Oct 26, 2018
8f245ae
Merge pull request #9 from mgage/develop_unit_tests2
mgage Oct 27, 2018
4ac192d
Merge branch 'develop_candidate_local' into develop_candidate
mgage Jan 1, 2019
d4f63e1
Merge branch 'develop' into new_develop_candidate_multilingual
mgage Jan 28, 2019
4f2e82f
Move unrelated test units out of the way so that it doesn't confuse r…
mgage Jan 28, 2019
3d94218
change to encodine(UTF-8) from :utf8 whereever possible.
mgage Mar 11, 2019
76c2f6e
Merge branch 'develop' into new_develop_candidate_multilingual
mgage Mar 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/PGcore.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ use Tie::IxHash;
use WeBWorK::Debug;
use MIME::Base64();
use PGUtil();

use Encode qw(encode_utf8 decode_utf8);
use utf8;
binmode(STDOUT, ":uft8");
##################################
# PGcore object
##################################
Expand Down Expand Up @@ -565,13 +567,15 @@ sub PG_restricted_eval {
sub decode_base64 ($) {
my $self = shift;
my $str = shift;
MIME::Base64::decode_base64($str);
$str = MIME::Base64::decode_base64($str);
decode_utf8($str);
}

sub encode_base64 ($;$) {
my $self = shift;
my $str = shift;
my $option = shift;
$str = encode_utf8($str);
MIME::Base64::encode_base64($str);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/PGloadfiles.pm
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ sub compile_file {
local($/);
$/ = undef; # allows us to treat the file as a single line

open(MACROFILE, "<$filePath") || die "Cannot open file: $filePath";
open(MACROFILE, "encoding(UTF-8)", $filePath) || die "Cannot open file: $filePath";
my $string = 'BEGIN {push @__eval__, __FILE__};' . "\n" . <MACROFILE>;
#warn "compiling $string";
my ($result,$error,$fullerror) = $self->PG_macro_file_eval($string);
Expand Down
2 changes: 1 addition & 1 deletion lib/Value/String.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ sub compare {
#
# Mark a string to be display verbatim
#
sub verb {shift; return "\\verb".chr(0x85).(shift).chr(0x85)}
sub verb {shift; return "\\verb".chr(0x1F).(shift).chr(0x1F)}

#
# Put normal strings into \text{} and others into \verb
Expand Down
27 changes: 22 additions & 5 deletions lib/WeBWorK/PG/IO.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
################################################################################

package WeBWorK::PG::IO;
use warnings qw(FATAL utf8);
use parent qw(Exporter);
use Encode qw( encode decode);
use JSON qw(decode_json);
use PGUtil qw(not_null);
use WeBWorK::Utils qw(path_is_subdir);
use WeBWorK::CourseEnvironment;

use utf8;
#binmode(STDOUT,":encoding(UTF-8)");
#binmode(STDIN,":encoding(UTF-8)");
#binmode(INPUT,":encoding(UTF-8)");
my $CE = new WeBWorK::CourseEnvironment({
webwork_dir => $ENV{WEBWORK_ROOT},
});
Expand Down Expand Up @@ -39,6 +44,7 @@ BEGIN {
our @SHARED_FUNCTIONS = qw(
includePGtext
read_whole_problem_file
read_whole_file
convertPath
fileFromPath
directoryFromPath
Expand Down Expand Up @@ -139,13 +145,24 @@ sub read_whole_file {
unless path_is_course_subdir($filePath);

local (*INPUT);
open(INPUT, "<$filePath") || die "$0: read_whole_file subroutine: <BR>Can't read file $filePath";
open(INPUT, "<:raw", $filePath) || die "$0: read_whole_file subroutine: <BR>Can't read file $filePath";
local($/)=undef;
my $string = <INPUT>; # can't append spaces because this causes trouble with <<'EOF' \nEOF construction
my $string = <INPUT>;
my $backup_string = $string;
# can't append spaces because this causes trouble with <<'EOF' \nEOF construction
my $success = utf8::decode($string);
unless ($success) {
warn "There was an error decoding $filePath as UTF-8, will try to upgrade";
utf8:upgrade($backup_string);
$string = $backup_string;
}
close(INPUT);
\$string;
}

# <:utf8 is more relaxed on input, <:encoding(UTF-8) would be better, but
# perhaps it's not so horrible to have lax input. encoding(UTF-8) tries to use require
# to import Encode, Encode::Alias::find_encoding and Safe raises an exception.
# haven't figured a way around this yet.
=item convertPath($path)

Currently a no-op. Returns $path unmodified.
Expand Down Expand Up @@ -201,7 +218,7 @@ sub createFile {

die 'Path is unsafe' unless path_is_course_subdir($fileName);

open(TEMPCREATEFILE, ">$fileName")
open(TEMPCREATEFILE, ">:encoding(UTF-8)",$fileName)
or die "Can't open $fileName: $!";
my @stat = stat TEMPCREATEFILE;
close(TEMPCREATEFILE);
Expand Down
Loading