gpt4 book ai didi

javascript - 为什么这个脚本不接受任何阿拉伯语输入?

转载 作者:行者123 更新时间:2023-12-04 08:25:13 25 4
gpt4 key购买 nike

下面的代码是Blogger平台的代码
但问题在于它不接受任何阿拉伯语输入
但是当通过这个工具转换文本时https://www.url-encode-decode.com/效果很好,请帮忙

var section = {
category: null,
"max-results": 6,
template: {
default:
'<div class="card card-masonry col-3-lg col-4-md col-6-sm"><div class="card__content"><div class="card__header"><a class="card__image flex-none" href="URL"><img src="IMG" /></a></div><div class="card__data"><h2 class="card__title card__space"><a href="URL">TITLE</a></h2><div class="card__meta display-flex justify-content-between"><time class="card__space meta__time flx-yc"><svg class="feather feather-clock" fill="none" height="24" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>TIME</time><a class="card__space meta__more flx-yc" href="URL" title="قراءة المزيد"><svg class="feather feather-arrow-left" fill="none" height="24" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><line x1="19" x2="5" y1="12" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg></a></div></div></div></div>',
empty: '<p class="alert">لا توجد مقالات</p>',
},
};
function forEach(items, callback) {
var i, item;
for (i = 0; (item = items[i++]); ) if (false === callback.call(item, i, item)) break;
return items;
}
function getCurrentData(element) {
var name, value;
var obj = {};
for (name in section) {
value = element.getAttribute("data-" + name);
if (value) obj[name] = value;
}
return obj;
}
function temp(content, data) {
var name;
for (name in data) content = content.replace(new RegExp(name, "g"), data[name]);
return content;
}
function getLabel(element, data) {
var name;
var category = data.category;
var script = document.createElement("script");
var src =
defaults.homeUrl +
"/feeds/posts/default?alt=json-in-script&callback=callbacks." +
category.replace(/[^A-Z0-9]/gi, "");
callbacks[category.replace(/[^A-Z0-9]/gi, "")] = function (json) {
var i, post;
var html = "";
var entry = json.feed.entry;
if (entry)
for (i = 0; (post = entry[i++]); ) {
var content = post.content;
var summary = post.summary;
var body = content ? content.$t : summary.$t;
var img = post.media$thumbnail;
var tempHtml = document.createElement("div");
tempHtml.innerHTML = body;
var imgHtml = tempHtml.querySelector("img");
html += temp(data.template, {
IMG: (img ? img.url : imgHtml ? imgHtml.src : defaults.image).replace(/s\B\d{2,4}-c/, defaults.imgSize),
TITLE: post.title.$t,
TIME: new Date(post.published.$t).toLocaleDateString("ar-EG", { month: "long", day: "2-digit" }),
SNIPPET: body.replace(/<[^>]*>?/g, "").substring(0, defaults.snippet) + "...",
URL: function () {
var i, link;
for (i = 0; (link = post.link[i++]); ) if (link.rel === "alternate") return link.href;
},
});
}
else html += section.template.empty;
element.innerHTML = html;
};
for (name in data) if (name !== "template") src += "&" + name + "=" + data[name];
script.src = src;
document.body.appendChild(script);
}
forEach(document.querySelectorAll(defaults.className), function (index, element) {
var currentData = getCurrentData(element);
if (currentData.category) {
if (!currentData["max-results"]) currentData["max-results"] = section["max-results"];
currentData.template = section.template["default"];
getLabel(element, currentData);
}
});
以这种方式添加部分名称时它不起作用
tag: "قسم 5", results: 10
但是当以这种方式添加时它工作正常
tag: "%D9%82%D8%B3%D9%85+5", results: 10
我想用阿拉伯语添加部门名称而不需要转换它
我怎么解决这个问题?
或者你们中的一个人会解决它吗?

最佳答案

您使用的url编码网络的功能之一:

  • 使用UTF-8编码将字符串转换为字节序列

  • UTF-8 可以存储完整的 Unicode 范围,因此可以用于阿拉伯语。也许您的项目中没有使用 utf-8。
    编辑:
    代替:
    <p class="alert">لا توجد مقالات</p>
    尝试:
    '<p class="alert"><?php echo 'لا توجد مقالات'; ?></p>'

    关于javascript - 为什么这个脚本不接受任何阿拉伯语输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65299978/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com