Vikram Pote
Vikram Pote

Reputation: 5579

Change + character to - in Html::encode decode function of YII2

I want to change the + character to - in Html encode decode functions of YII2. How should i change that? Does any one know?

I try to do this changes in BaseHtml helper class of yii2 but not working.

public static function encode($content, $doubleEncode = true)
{
    return str_replace("+","-",htmlspecialchars($content, ENT_QUOTES | ENT_SUBSTITUTE, Yii::$app ? Yii::$app->charset : 'UTF-8', $doubleEncode));
}

public static function decode($content)
{

    return htmlspecialchars_decode(str_replace("-","+",$content), ENT_QUOTES);
}

Upvotes: 1

Views: 1098

Answers (1)

arogachev
arogachev

Reputation: 33538

This has nothing to do with encode method. Also you should not modify any files under vendor directory, it will be overriden on the next composer update and overall it's very bad practice.

Process this separately using str_replace for example:

Minus to plus:

str_replace('-', '+', $string);

Backwards:

str_replace('+', '-', $string);

Place it in separate methods or just one method with additional parameter.

Official docs:

Upvotes: 1

Related Questions