HTML - 阿拉伯语支持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3601760/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML - Arabic Support
提问by Moon
i have a website in which i have to put some lines in Arabic.... how to do it...
我有一个网站,我必须在其中用阿拉伯语写几行.... 怎么做...
where to get the Arabic text characters... how to make the page support Arabic...
从哪里获取阿拉伯文字字符...如何使页面支持阿拉伯语...
i have to put a line per page and there is a lotta lotta pages so can't go around making images and putting them...
我必须在每页上放一行,而且有很多页,所以不能四处制作图像并放置它们...
采纳答案by Quentin
The W3C has a good introduction.
W3C 有一个很好的介绍。
In short:
简而言之:
HTML is a text markup language. Text means any characters, not just ones in ASCII.
HTML 是一种文本标记语言。文本意味着任何字符,而不仅仅是 ASCII 中的字符。
- Save your text using a character encoding that includes the characters you want (UTF-8 is a good bet). This will probably require configuring your editor in a way that is specific to the particular editor you are using. (Obviously it also requires that you have a way to input the characters you want)
- Make sure your server sends the correct character encoding in the headers (how you do this depends on the server software you us)
- If the document you serve over HTTP specifies its encoding internally, then make sure that is correct too
- If anything happens to the document between you saving it and it being served up (e.g. being put in a database, being munged by a server side script, etc) then make sure that the encoding isn't mucked about with on the way.
- 使用包含所需字符的字符编码保存文本(UTF-8 是一个不错的选择)。这可能需要以特定于您正在使用的特定编辑器的方式配置您的编辑器。(显然它也需要你有办法输入你想要的字符)
- 确保您的服务器在标头中发送正确的字符编码(您如何执行此操作取决于您使用的服务器软件)
- 如果您通过 HTTP 提供的文档在内部指定了其编码,请确保它也是正确的
- 如果文档在保存和提供服务之间发生任何事情(例如,被放入数据库,被服务器端脚本修改等),请确保编码不会在途中被搞砸。
You can also represent any unicode character with ASCII
您还可以用 ASCII表示任何 unicode 字符
回答by Moon
This is the answer that was required but everybody answered only part one of many.
这是必需的答案,但每个人都只回答了其中的一部分。
- Step 1 -You cannot have the multilingual characters in unicode document.. convert the document to
UTF-8
document
- 第 1 步 -您不能在 unicode 文档中使用多语言字符。将文档转换为
UTF-8
文档
advanced editors don't make it simple for you... go low level...
use notepad to save the document as meName.html & change the encoding
type to UTF-8
高级编辑器不会让你变得简单...低级...
使用记事本将文档保存为 meName.html 并将编码
类型更改为 UTF-8
Step 2 -Mention in your html page that you are going to use such characters by
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
Step 3 -When you put in some characters make sure your container tags have the following 2 properties set
dir='rtl' lang='ar'
- Step 4 -Get the characters from some specific tool\editor or online editor like i did with Arabic-Keyboard.org
第 2 步 -在您的 html 页面中提及您将使用这些字符
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
第 3 步 -当您输入一些字符时,请确保您的容器标签设置了以下 2 个属性
dir='rtl' lang='ar'
- 第 4 步 -从一些特定的工具\编辑器或在线编辑器中获取字符,就像我在阿拉伯键盘.org 上所做的那样
example
例子
<p dir="rtl" lang="ar" style="color:#e0e0e0;font-size:20px;">????? ??????? ??????</p>
NOTE:font type, font family, font face setting will have no effect on special characters
注意:字体类型、字体系列、字体设置对特殊字符没有影响
回答by Jimmy Collins
Won't you need the ensure the area where you display the Arabic is Right-to-Left orientated also?
您不需要确保显示阿拉伯语的区域也是从右到左的吗?
e.g.
例如
<p dir="rtl">
回答by 2ndkauboy
You not only have to put the meta tag, telling that it is UTF-8 but really make the document UTF-8. You can do that with good editors (like notepad++) by converting them to "unicode" or "UTF-8 without BOM". Than you can simply use arabic characters
您不仅要放置元标记,告诉它是 UTF-8,还要真正使文档成为 UTF-8。您可以使用优秀的编辑器(如记事本++)将它们转换为“unicode”或“UTF-8 without BOM”。比你可以简单地使用阿拉伯字符
As this page is UTF-8, here are some examples (I hope I don't write anything rude here): ???
由于这个页面是 UTF-8,这里有一些例子(我希望我不要在这里写任何粗鲁的东西):???
If you use a server side scripting language make sure that it does not output the page in a different encoding. In PHP e.g. you can set it like this:
如果您使用服务器端脚本语言,请确保它不会以不同的编码输出页面。例如,在 PHP 中,您可以这样设置:
header('Content-Type: text/html; charset=utf-8');
回答by Lekensteyn
If you don't even know where to get Arabic characters, but you want to display them, then you're doing something wrong.
如果您甚至不知道从哪里获取阿拉伯字符,但您想显示它们,那么您就做错了。
Save files containing Arabic characters with encoding UTF-8. A good editor allows you to set the character encoding.
In the HTML page, place the following after <head>
:
保存包含编码为 UTF-8 的阿拉伯字符的文件。一个好的编辑器允许您设置字符编码。在 HTML 页面中,将以下内容放在 之后<head>
:
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
If you're using XHTML:
如果您使用的是 XHTML:
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
That's it.
就是这样。
An alternative way (without messing with the encoding of a file), is using HTML escape sequences. This website does that jobs for you: http://www.htmlescape.net/
另一种方法(不搞乱文件编码)是使用 HTML 转义序列。这个网站为你做这些工作:http: //www.htmlescape.net/
回答by Ali
i edit the html page with notepad ++ ,set encoding to utf-8 and its work
我用记事本++编辑html页面,将编码设置为utf-8及其工作
回答by bottleboot
As mentioned above, by default text editors will not use UTF-8 as the standard encoding for documents. However most editors will allow you to change that in the settings. Even for each specific document.
如上所述,默认情况下,文本编辑器不会使用 UTF-8 作为文档的标准编码。然而,大多数编辑器将允许您在设置中更改它。甚至对于每个特定的文件。