问题
I am using a jQuery to match text between > < and changing it as follows, from this:
<a href="page.php">Mt 5: 2</a><br>
<a href="page.php">Nd 14: 25</a
To this:
<a href="page.php?book=80&chapter=5&vmin=2">Mt 5: 2</a>
<a href="page.php?book=95&chapter=15&vmin=25">Nd 14: 25</a>
The code is:
var myarray = { 'Mt': 80, 'Lu': 81, 'Rv': 92, 'Nd': 95 }; // you can add more values
$(document).ready(function() {
$("a[href='page.php']").each(function(index, element){
href = $(element).attr('href'); // get the href
text = $(element).text().split(' '); // get the text and split it with space
$(element).attr('href', href + "?book=" + $.trim(myarray[text[0]]) + "&chapter=" + $.trim(text[1].slice(0, -1)) + "&vmin=" + $.trim(text[2])); //create desired href and replace it with older-one
});
});
However, when I try Arabic letters instead, it doesn't work. Like: <a href="page.php">كم 5: 2</a> and var myarray = {'كم':80
I tried changing the charset to "windows-1256" or "utf-8" in the php file meta tag or script tag, but still it doesn't read the Arabic and just shows the link as follows <a href="page.php?book=&chapter=5&vmin=2">Mt 5: 2</a> as if there is nothing to put after book=.
来源:https://stackoverflow.com/questions/46560121/arabic-encoding-for-matched-texted-with-querystring