A
A
Abdulla Timershin2019-12-25 01:56:14
JavaScript
Abdulla Timershin, 2019-12-25 01:56:14

Is it possible to add cyrillic encoding to rawurlcencode exceptions?

Good evening!
I need php to encode a string into url format like rawurlcencode does, but it doesn't encode cyrillic. Is there such a function?
Well, or if you create your own function to replace non-alphanumeric characters, then how can you specify the% 22 character (quotes) there?

function myUrlEncode($string) {
    $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
    $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
    return str_replace($entities, $replacements, urlencode($string));
}

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
sim3x, 2019-02-21
@Chefranov

const players_online = '{"response":{"player_count":1080,"result":1}}';
const user = JSON.parse(players_online);
console.log(user.response.player_count);

O
Oleg, 2019-02-21
@402d

user.response.player_count

A
AUser0, 2019-12-25
@flawlessattila

Or \0x22, also a perfectly kosher way of representing double quotes in the $replacements array.

F
freeExec, 2019-12-25
@freeExec

Try different options:
"""

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question