Skip to content

Commit

Permalink
fix: restore chars in files that have beed wrongly converted to utf8
Browse files Browse the repository at this point in the history
  • Loading branch information
Pol Torrent i Soler committed Sep 28, 2023
1 parent 3317f64 commit a8f0d76
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 44 deletions.
18 changes: 9 additions & 9 deletions quizzes/lib/HList.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,26 @@ public function add($item) {
public function __call($m, $a) {
if(isset($this->$m) && is_callable($this->$m))
return call_user_func_array($this->$m, $a);
else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m]))
return call_user_func_array($this->»dynamics[$m], $a);
else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m]))
return call_user_func_array($this->»dynamics[$m], $a);
else if('toString' == $m)
return $this->__toString();
else
throw new HException('Unable to call «'.$m.'»');
throw new HException('Unable to call «'.$m.'»');
}
function __toString() { return $this->toString(); }
}
function HList_0(&$»this) {
if($»this->q === null) {
function HList_0(&$»this) {
if($»this->q === null) {
return null;
} else {
return $»this->q[0];
return $»this->q[0];
}
}
function HList_1(&$»this) {
if($»this->h === null) {
function HList_1(&$»this) {
if($»this->h === null) {
return null;
} else {
return $»this->h[0];
return $»this->h[0];
}
}
12 changes: 6 additions & 6 deletions quizzes/lib/Hash.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public function getIterator() {
public function toString() {
$s = "{";
$it = $this->keys();
$»it = $it;
while($»it->hasNext()) {
$i = $»it->next();
$»it = $it;
while($»it->hasNext()) {
$i = $»it->next();
$s .= $i;
$s .= " => ";
$s .= Std::string($this->get($i));
Expand Down Expand Up @@ -56,12 +56,12 @@ public function set($key, $value) {
public function __call($m, $a) {
if(isset($this->$m) && is_callable($this->$m))
return call_user_func_array($this->$m, $a);
else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m]))
return call_user_func_array($this->»dynamics[$m], $a);
else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m]))
return call_user_func_array($this->»dynamics[$m], $a);
else if('toString' == $m)
return $this->__toString();
else
throw new HException('Unable to call »'.$m.'»');
throw new HException('Unable to call »'.$m.'»');
}
function __toString() { return $this->toString(); }
}
12 changes: 6 additions & 6 deletions quizzes/lib/IntHash.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public function getIterator() {
public function toString() {
$s = "{";
$it = $this->keys();
$»it = $it;
while($»it->hasNext()) {
$i = $»it->next();
$»it = $it;
while($»it->hasNext()) {
$i = $»it->next();
$s .= _hx_string_rec($i, "");
$s .= " => ";
$s .= Std::string($this->get($i));
Expand Down Expand Up @@ -55,12 +55,12 @@ public function set($key, $value) {
public function __call($m, $a) {
if(isset($this->$m) && is_callable($this->$m))
return call_user_func_array($this->$m, $a);
else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m]))
return call_user_func_array($this->»dynamics[$m], $a);
else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m]))
return call_user_func_array($this->»dynamics[$m], $a);
else if('toString' == $m)
return $this->__toString();
else
throw new HException('Unable to call «'.$m.'»');
throw new HException('Unable to call «'.$m.'»');
}
function __toString() { return $this->toString(); }
}
72 changes: 71 additions & 1 deletion quizzes/lib/com/wiris/quizzes/impl/ActionCommands.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,74 @@ public function __construct(){}
static $COMMANDS;
function __toString() { return 'com.wiris.quizzes.impl.ActionCommands'; }
}
com_wiris_quizzes_impl_ActionCommands::$COMMANDS = new _hx_array(array("avalua", "vurdere", "bewerten", "αξιολογώ", "evaluate", "evalúa", "évaluer", "valutare", "evaluere", "avalie"));
com_wiris_quizzes_impl_ActionCommands::$COMMANDS = new _hx_array(array("avalua", "vurdere", "bewerten", com_wiris_quizzes_impl_ActionCommands_0() . com_wiris_quizzes_impl_ActionCommands_1() . com_wiris_quizzes_impl_ActionCommands_2() . com_wiris_quizzes_impl_ActionCommands_3() . com_wiris_quizzes_impl_ActionCommands_4() . com_wiris_quizzes_impl_ActionCommands_5() . com_wiris_quizzes_impl_ActionCommands_6() . com_wiris_quizzes_impl_ActionCommands_7(), "evaluate", "eval" . com_wiris_quizzes_impl_ActionCommands_8() . "a", com_wiris_quizzes_impl_ActionCommands_9() . "valuer", "valutare", "evaluere", "avalie"));
function com_wiris_quizzes_impl_ActionCommands_0() {
{
$s = new haxe_Utf8(null);
$s->addChar(945);
return $s->toString();
}
}
function com_wiris_quizzes_impl_ActionCommands_1() {
{
$s = new haxe_Utf8(null);
$s->addChar(958);
return $s->toString();
}
}
function com_wiris_quizzes_impl_ActionCommands_2() {
{
$s = new haxe_Utf8(null);
$s->addChar(953);
return $s->toString();
}
}
function com_wiris_quizzes_impl_ActionCommands_3() {
{
$s = new haxe_Utf8(null);
$s->addChar(959);
return $s->toString();
}
}
function com_wiris_quizzes_impl_ActionCommands_4() {
{
$s = new haxe_Utf8(null);
$s->addChar(955);
return $s->toString();
}
}
function com_wiris_quizzes_impl_ActionCommands_5() {
{
$s = new haxe_Utf8(null);
$s->addChar(959);
return $s->toString();
}
}
function com_wiris_quizzes_impl_ActionCommands_6() {
{
$s = new haxe_Utf8(null);
$s->addChar(947);
return $s->toString();
}
}
function com_wiris_quizzes_impl_ActionCommands_7() {
{
$s = new haxe_Utf8(null);
$s->addChar(974);
return $s->toString();
}
}
function com_wiris_quizzes_impl_ActionCommands_8() {
{
$s = new haxe_Utf8(null);
$s->addChar(250);
return $s->toString();
}
}
function com_wiris_quizzes_impl_ActionCommands_9() {
{
$s = new haxe_Utf8(null);
$s->addChar(233);
return $s->toString();
}
}
71 changes: 49 additions & 22 deletions quizzes/lib/com/wiris/quizzes/impl/HTMLTools.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1673,51 +1673,42 @@ public function expandVariablesText($text, $textvariables) {
return $this->replaceVariablesInsideHTML($text, $textvariables, com_wiris_quizzes_impl_MathContent::$TYPE_TEXT, false);
}
public function encodeMathML($html) {
$opentag = "«";
$closetag = "»";
$quote = "¨";
$amp = "§";
$start = null;
$end = 0;
while(($start = _hx_index_of($html, "<math", $end)) !== -1) {
$closemath = "</math>";
$end = _hx_index_of($html, $closemath, $start) + strlen($closemath);
$formula = _hx_substr($html, $start, $end - $start);
$formula = str_replace("<", $opentag, $formula);
$formula = str_replace(">", $closetag, $formula);
$formula = str_replace("\"", $quote, $formula);
$formula = str_replace("&", $amp, $formula);
$formula = str_replace("<", com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_LT, $formula);
$formula = str_replace(">", com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_GT, $formula);
$formula = str_replace("\"", com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_QUOT, $formula);
$formula = str_replace("&", com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_AMP, $formula);
$html = _hx_substr($html, 0, $start) . $formula . _hx_substr($html, $end, null);
$end = $start + strlen($formula);
unset($formula,$closemath);
}
return $html;
}
public function decodeMathML($html) {
$opentag = "«";
$closetag = "»";
$quote = "¨";
$amp = "§";
$closemath = $opentag . "/math" . $closetag;
$closemath = com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_LT . "/math" . com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_GT;
$start = null;
$end = 0;
while(($start = _hx_index_of($html, $opentag . "math", $end)) !== -1) {
while(($start = _hx_index_of($html, com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_LT . "math", $end)) !== -1) {
$end = _hx_index_of($html, $closemath, $start) + strlen($closemath);
$formula = _hx_substr($html, $start, $end - $start);
$formula = com_wiris_util_xml_WXmlUtils::htmlUnescape($formula);
$formula = str_replace($opentag, "<", $formula);
$formula = str_replace($closetag, ">", $formula);
$formula = str_replace($quote, "\"", $formula);
$formula = str_replace($amp, "&", $formula);
$formula = str_replace(com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_LT, "<", $formula);
$formula = str_replace(com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_GT, ">", $formula);
$formula = str_replace(com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_QUOT, "\"", $formula);
$formula = str_replace(com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_AMP, "&", $formula);
$html = _hx_substr($html, 0, $start) . $formula . _hx_substr($html, $end, null);
$end = $start + strlen($formula);
unset($formula);
}
return $html;
}
public function isMathMLEncoded($html) {
$opentag = "«";
return _hx_index_of($html, $opentag . "math", null) !== -1;
return _hx_index_of($html, com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_LT . "math", null) !== -1;
}
public function extractVariableNames($html) {
if($this->isMathMLEncoded($html)) {
Expand Down Expand Up @@ -1947,6 +1938,10 @@ static function insertStringInSortedArray($s, $a) {
}
}
}
static $SAFE_MATHML_LT;
static $SAFE_MATHML_GT;
static $SAFE_MATHML_QUOT;
static $SAFE_MATHML_AMP;
static function encodeUnicodeChars($mathml) {
$sb = new StringBuf();
$i = null;
Expand Down Expand Up @@ -2051,6 +2046,10 @@ static function getEmptyCalcMeSession() {
function __toString() { return 'com.wiris.quizzes.impl.HTMLTools'; }
}
com_wiris_quizzes_impl_HTMLTools::$EMPTY_CALCME_SESSION = "<wiriscalc version=\"3.2\">\x0A" . " <title>\x0A" . " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\x0A" . " <mtext></mtext>\x0A" . " </math>\x0A" . " </title>\x0A" . " <session version=\"3.0\">\x0A" . " <group>\x0A" . " <command>\x0A" . " <input>\x0A" . " <math xmlns=\"http://www.w3.org/1998/Math/MathML\"/>\x0A" . " </input>\x0A" . " </command>\x0A" . " </group>\x0A" . " </session>\x0A" . "</wiriscalc>";
com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_LT = com_wiris_quizzes_impl_HTMLTools_21();
com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_GT = com_wiris_quizzes_impl_HTMLTools_22();
com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_QUOT = com_wiris_quizzes_impl_HTMLTools_23();
com_wiris_quizzes_impl_HTMLTools::$SAFE_MATHML_AMP = com_wiris_quizzes_impl_HTMLTools_24();
function com_wiris_quizzes_impl_HTMLTools_0(&$»this, &$_g, &$_g1, &$a, &$answer, &$answers, &$compound, &$h, &$i, &$i1, &$s) {
if($»this->isMathMLString($s)) {
return com_wiris_quizzes_impl_MathContent::$TYPE_MATHML;
Expand All @@ -2061,7 +2060,7 @@ function com_wiris_quizzes_impl_HTMLTools_0(&$»this, &$_g, &$_g1, &$a, &$answer
function com_wiris_quizzes_impl_HTMLTools_1(&$»this, &$close, &$e, &$i, &$it, &$n, &$open, &$sb, &$separators) {
{
$s = new haxe_Utf8(null);
$s->addChar(haxe_Utf8::charCodeAt($separators, com_wiris_quizzes_impl_HTMLTools_21($close, $e, $i, $it, $n, $open, $s, $sb, $separators)));
$s->addChar(haxe_Utf8::charCodeAt($separators, com_wiris_quizzes_impl_HTMLTools_25($close, $e, $i, $it, $n, $open, $s, $sb, $separators)));
return $s->toString();
}
}
Expand Down Expand Up @@ -2194,7 +2193,35 @@ function com_wiris_quizzes_impl_HTMLTools_20(&$centerBaseline, &$crossOriginEnab
return $proxyUrl . "?service=render&";
}
}
function com_wiris_quizzes_impl_HTMLTools_21(&$close, &$e, &$i, &$it, &$n, &$open, &$s, &$sb, &$separators) {
function com_wiris_quizzes_impl_HTMLTools_21() {
{
$s = new haxe_Utf8(null);
$s->addChar(171);
return $s->toString();
}
}
function com_wiris_quizzes_impl_HTMLTools_22() {
{
$s = new haxe_Utf8(null);
$s->addChar(187);
return $s->toString();
}
}
function com_wiris_quizzes_impl_HTMLTools_23() {
{
$s = new haxe_Utf8(null);
$s->addChar(168);
return $s->toString();
}
}
function com_wiris_quizzes_impl_HTMLTools_24() {
{
$s = new haxe_Utf8(null);
$s->addChar(167);
return $s->toString();
}
}
function com_wiris_quizzes_impl_HTMLTools_25(&$close, &$e, &$i, &$it, &$n, &$open, &$s, &$sb, &$separators) {
if($i < $n) {
return $i;
} else {
Expand Down

0 comments on commit a8f0d76

Please sign in to comment.