Returns if the defined string ends with a substring, defined by characters, usable as a TLD.

@param  string $stringToCheck
@param  bool   $convertUniCode Convert unicode strings to Puny code? (Default = FALSE)
@return boolean
960863
public static function EndsWithValidTldString( string &$stringToCheck, bool $convertUniCode = false ) : bool
   {

      if ( $convertUniCode ) { $stringToCheck = idnToASCII( $stringToCheck ); }

      return (bool) \preg_match(
         '~\.(' . static::DOUBLE_TLDS . '|' . static::KNOWN_FORMAT . ')\.?$~i',
         $stringToCheck
      );

   }
269299
public static String stripTopLevelTag(String strText, String strTag)
    {
        int iStart = MenuParser.getFirstNonWhitespace(strText);
        int iEnd = MenuParser.getLastNonWhitespace(strText);
        if ((iStart != -1) && (iEnd != -1))
        {
            String strStartTag = Utility.startTag(strTag);
            String strEndTag = Utility.endTag(strTag);
            if (strText.substring(iStart, iStart + strStartTag.length()).equalsIgnoreCase(strStartTag))
                if (strText.substring(iEnd - strEndTag.length() + 1, iEnd + 1).equalsIgnoreCase(strEndTag))
                    strText = strText.substring(iStart + strStartTag.length(), iEnd - strEndTag.length() + 1);
        }
        return strText;
    }
373055
protected function checkUriSegmentMatch($key, $string, $returnOnTrue = null, $returnOnFalse = null)
    {
        if (\array_key_exists($key, $this->parts) && $this->parts[$key] === $string) {
            return $returnOnTrue ?? true;
        }

        return $returnOnFalse ?? false;
    }
405862
def string_end_with_semicolon?(str)
      i = str.size - 1
      while i >= 0
        c = str[i].ord
        i -= 1

        next if WHITESPACE_ORDINALS[c]

        return c === 0x3B
      end

      true
    end
565261
function _convertError($errorCode)
    {
		switch ($errorCode) {
			case '#NULL!':	return pack("C", 0x00);
			case '#DIV/0!':	return pack("C", 0x07);
			case '#VALUE!':	return pack("C", 0x0F);
			case '#REF!':	return pack("C", 0x17);
			case '#NAME?':	return pack("C", 0x1D);
			case '#NUM!':	return pack("C", 0x24);
			case '#N/A':	return pack("C", 0x2A);
		}
		return pack("C", 0xFF);
    }
808852
public static function reverseIfLittleEndian($toCheck)
    {
        // Little endian, needs to be reversed
        if (unpack('S',"\x01\x00")[1] === 1)
        {
            // Reverse an array
            if (is_array($toCheck))
            {
                return array_reverse($toCheck);
            }

            // Reverse a string
            else
            {
                return strrev($toCheck);
            }
        }

        // Big endian, no need to reverse
        else
        {
            return $toCheck;
        }
    }
154162
public function validate($code) {
		$code = $this->_normalize($code, ['clean' => true, 'case' => true]);

		if (strlen($code) !== ($this->_parts * $this->_partLength)) {
			return false;
		}
		$parts = str_split($code, $this->_partLength);

		foreach ($parts as $number => $part) {
			$expected = substr($part, -1);
			$result = $this->_checkdigitAlg1($number + 1, $x = substr($part, 0, strlen($part) - 1));

			if ($result !== $expected) {
				return false;
			}
		}
		return true;
	}
794154
protected boolean parse(HttpCode<TRANS, ?> code, String cntnt) {
		byte bytes[] = cntnt.getBytes();
		
		int cis,cie=-1,cend;
		int sis,sie,send;
		String name;
		ArrayList<String> props = new ArrayList<String>();
		do {
			// Clear these in case more than one Semi
			props.clear(); // on loop, do not want mixed properties
			name=null;
			
			cis = cie+1; // find comma start
			while(cis<bytes.length && Character.isSpaceChar(bytes[cis]))++cis;
			cie = cntnt.indexOf(',',cis); // find comma end
			cend = cie<0?bytes.length:cie; // If no comma, set comma end to full length, else cie
			while(cend>cis && Character.isSpaceChar(bytes[cend-1]))--cend;
			// Start SEMIS
			sie=cis-1; 
			do {
				sis = sie+1;  // semi start is one after previous end
				while(sis<bytes.length && Character.isSpaceChar(bytes[sis]))++sis;	
				sie = cntnt.indexOf(';',sis);
				send = sie>cend || sie<0?cend:sie;  // if the Semicolon is after the comma, or non-existent, use comma end, else keep
				while(send>sis && Character.isSpaceChar(bytes[send-1]))--send;
				if(name==null) { // first entry in Comma set is the name, not a property
					name = new String(bytes,sis,send-sis);
				} else { // We've looped past the first Semi, now process as properties
					// If there are additional elements (more entities within Semi Colons)
					// apply Properties
					int eq = cntnt.indexOf('=',sis);
					if(eq>sis && eq<send) {
						props.add(new String(bytes,sis,eq-sis));
						props.add(new String(bytes,eq+1,send-(eq+1)));
					}
				}
				// End Property
			} while(sie<=cend && sie>=cis); // End SEMI processing
			// Now evaluate Comma set and return if true
			if(eval(code,name,props))return true; // else loop again to check next comma
		} while(cie>=0); // loop to next comma
		return false; // didn't get even one match
	}
883298
public function convertResultCodeToString($resultCode)
    {
        switch ($resultCode) {
            case TestResult::SKIPPED:
                return 'skipped';
            case TestResult::PENDING:
                return 'pending';
            case TestResult::FAILED:
                return 'failed';
            case StepResult::UNDEFINED:
                return 'undefined';
        }

        return 'passed';
    }
487051
private static boolean isUnM49AreaCode(String code) {
        if (code.length() != 3) {
            return false;
        }

        for (int i = 0; i < 3; ++i) {
            final char character = code.charAt(i);
            if (!(character >= '0' && character <= '9')) {
                return false;
            }
        }

        return true;
    }
44219
public static function isValidCode( $code ) {
		return
			strcspn( $code, ":/\\\000" ) === strlen( $code )
			&& !preg_match( Title::getTitleInvalidRegex(), $code );
	}
104314
protected static function recode( $string, $fromCharset, $toCharset, $stop = false )
    {
        $codec = eZTextCodec::instance( $fromCharset, $toCharset, false );
        if ( $codec )
        {
            $string = $codec->convertString( $string );
        }

        return $string;
    }
1211909
public static function endsWith($haystack, $needle, $case_sensitive = true)
    {
        $status = false;

        $compare_func = $case_sensitive ? 'mb_strrpos' : 'mb_strripos';

        foreach ((array)$needle as $each_needle) {
            $expectedPosition = mb_strlen($haystack) - mb_strlen($each_needle);
            $status = $each_needle === '' || $compare_func($haystack, $each_needle, 0) === $expectedPosition;
            if ($status) {
                break;
            }
        }

        return $status;
    }
653734
static function convertStringToUnicode( $str )
    {
        $unicodeValues = array();
        $strLen = strlen( $str );
        for ( $offset = 0; $offset < $strLen; )
        {
            $charLen = 1;
            $unicodeValue = eZUTF8Codec::fromUTF8( $str, $offset, $charLen );
            if ( $unicodeValue !== false )
                $unicodeValues[] = $unicodeValue;
            $offset += $charLen;
        }
        return $unicodeValues;
    }
478105
public function doesStringEndWith(string $string, string $test): bool {
		$strlen = strlen($string);
		$testlen = strlen($test);
		if ($testlen > $strlen) {
			return false;
		}
		return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
	}
1221542
private function endswith($string, $suffix)
	{
		$strlen = strlen($string);
		$testlen = strlen($suffix);
		if ($testlen > $strlen) {
			return false;
		}

		return substr_compare($string, $suffix, -$testlen) === 0;
	}
532068
public function checkToken(string $tokenToCheck): bool
    {
        //Throw Exception
        $tokenInfos = $this->obtainToken();

        $token      = $tokenInfos->token;
        $dateCreate = $tokenInfos->date;
        $timeExpire = $tokenInfos->expire;

        if ($token !== $tokenToCheck) {
            return false;
        }

        $limitDate = new DateTime;
        $limitDate->modify('-'.$timeExpire.' minutes');
        
        unset($_SESSION['formsTokens'][$this->formId]);
        
        if ($dateCreate < $limitDate) {
            return false;
        }

        return true;
    }