Skip to content

Commit

Permalink
New developmental setting to force UTF for the whole server
Browse files Browse the repository at this point in the history
Plus, some optimisation on the way encoding is stored (in the session).
  • Loading branch information
moodler committed Apr 27, 2004
1 parent 37aaf07 commit cec0a0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions config-dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@
//
// Setting this to true will enable admins to edit any post at any time
// $CFG->admineditalways = true;
//
// This setting will put Moodle in Unicode mode. It's very new and
// most likely doesn't work yet. THIS IS FOR DEVELOPERS ONLY, IT IS
// NOT RECOMMENDED FOR PRODUCTION SITES
// $CFG->unicode = true;



Expand Down
1 change: 1 addition & 0 deletions lib/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class object {};

if (isset($_GET['lang'])) {
$SESSION->lang = $lang;
$SESSION->encoding = get_string('thischarset');
}
if (empty($CFG->lang)) {
$CFG->lang = "en";
Expand Down
14 changes: 8 additions & 6 deletions lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function choose_from_menu ($options, $name, $selected="", $nothing="choose", $sc
$output = "<select name=\"$name\" $javascript>\n";
if ($nothing) {
$output .= " <option value=\"$nothingvalue\"\n";
if ($nothingvalue == $selected) {
if ($nothingvalue === $selected) {
$output .= " selected=\"true\"";
}
$output .= ">$nothing</option>\n";
Expand Down Expand Up @@ -931,13 +931,15 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
// Add a stylesheet for the HTML editor
$meta = "<style type=\"text/css\">@import url($CFG->wwwroot/lib/editor/htmlarea.css);</style>\n$meta\n";

// Specify character set ... default is iso-8859-1 but some languages might need something else
// Could be optimised by carrying the charset variable around in $USER
if (current_language() == "en") {
$meta = "<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\" />\n$meta\n";
// Character set could be optimised by carrying the charset variable around in $USER
if (!empty($CFG->unicode)) {
$encoding = "utf-8";
} else if (!empty($SESSION->encoding)) {
$encoding = $SESSION->encoding;
} else {
$meta = "<meta http-equiv=\"content-type\" content=\"text/html; charset=".get_string("thischarset")."\" />\n$meta\n";
$encoding = get_string("thischarset");
}
$meta = "<meta http-equiv=\"content-type\" content=\"text/html; charset=$encoding\" />\n$meta\n";

if ( get_string("thisdirection") == "rtl" ) {
$direction = " dir=\"rtl\"";
Expand Down

0 comments on commit cec0a0f

Please sign in to comment.