You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何对URL中的阿拉伯语词汇编码及将截图URL编码为指定格式

Alright, let's tackle your two questions about Arabic URL encoding step by step—this is a common gotcha since URLs only speak ASCII, right?

1. How to Encode Arabic Vocabulary in URLs

URLs are restricted to ASCII characters, so any non-ASCII text (like Arabic) needs to be converted into percent-encoded format (each byte of the UTF-8 representation is prefixed with %). Here are reliable, practical ways to do it:

  • Using Python: Super straightforward. The urllib.parse.quote() function handles UTF-8 encoding by default (perfect for Arabic script). Example:

    from urllib.parse import quote
    
    arabic_text = "ثورة زراعية باستخدام الاسم النانوية"
    encoded_text = quote(arabic_text)
    print(encoded_text)  # Outputs the exact percent-encoded string from your target URL
    
  • Using JavaScript: In browsers or Node.js, use encodeURIComponent() (avoid encodeURI() here—it skips characters needed for path segments). Example:

    const arabicText = "ثورة زراعية باستخدام الاسم النانوية";
    const encodedText = encodeURIComponent(arabicText);
    console.log(encodedText); // Matches the encoded segment in your target URL
    
  • Manual Calculation (for understanding only): If you want to see the mechanics:

    1. Convert the Arabic text to UTF-8 bytes. For example, the character "ث" becomes the byte sequence D8 AB.
    2. Prefix each byte with %, so D8 AB becomes %D8%AB.
    3. Concatenate all encoded bytes to form the full string.
      Don't do this manually for real use cases—it's error-prone. Stick to the code methods above.
2. How to Encode the Arabic URL from Your Screenshot to the Target URL

Assuming the original Arabic path segment in your screenshot is ثورة زراعية باستخدام الاسم النانوية, here's exactly how to build the target URL:

  1. Isolate the Arabic segment: Pull out the Arabic text from the screenshot's URL—this is the only part that needs encoding.
  2. Encode the Arabic text: Use either the Python or JavaScript method above. You'll get this encoded string:
    %D8%AB%D9%88%D8%B1%D8%A9-%D8%B2%D8%B1%D8%A7%D8%B9%D9%8A%D8%A9-%D8%A8%D8%A7%D8%B3%D8%AA%D8%AE%D8%AF%D8%A7%D9%85-%D8%A7%D9%84%D8%A7%D9%94%D8%B3%D9%85%D8%AF%D8%A9-%D8%A7%D9%84%D9%86%D8%A7%D9%86%D9%88%D9%8A%D8%A9
  3. Assemble the full URL: Take the base URL https://arabian-chemistry.com/wp-content/uploads/2018/01/, append the encoded Arabic string, then add the query parameter ?x15001. That's your exact target URL.

Pro tip: If you're working with a full URL from the screenshot, make sure to only encode the path/query parts containing Arabic—never encode the scheme (https://) or domain (arabian-chemistry.com), as those must stay in plain ASCII.

内容的提问来源于stack exchange,提问作者Génius Chemist

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:45:32