Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1110 from francescom/master
Browse files Browse the repository at this point in the history
Incapsulated definitions of mb_ord and mb_chr into a if(!function_exi…
  • Loading branch information
ksafranski committed Mar 21, 2020
2 parents 97f1331 + dbd94f8 commit b2ef139
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/diff_match_patch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2071,14 +2071,18 @@ function __toString(){
function charCodeAt($str, $pos) {
return mb_ord(mb_substr($str, $pos, 1));
}
function mb_ord($v) {
$k = mb_convert_encoding($v, 'UCS-2LE', 'UTF-8');
$k1 = ord(substr($k, 0, 1));
$k2 = ord(substr($k, 1, 1));
return $k2 * 256 + $k1;
if(!function_exists('mb_ord')) {
function mb_ord($v) {
$k = mb_convert_encoding($v, 'UCS-2LE', 'UTF-8');
$k1 = ord(substr($k, 0, 1));
$k2 = ord(substr($k, 1, 1));
return $k2 * 256 + $k1;
}
}
function mb_chr($num){
return mb_convert_encoding('&#'.intval($num).';', 'UTF-8', 'HTML-ENTITIES');
if(!function_exists('mb_chr')) {
function mb_chr($num){
return mb_convert_encoding('&#'.intval($num).';', 'UTF-8', 'HTML-ENTITIES');
}
}

/**
Expand Down

0 comments on commit b2ef139

Please sign in to comment.