2013-03-17 52 views
0

我需要file_get_contents()函数的帮助。使用file_get_contents和希伯来字符串

当我试图从包含一些希伯来字符的url中获取数据时,我从主机(无效链接)收到错误。

例如:

file_get_contents('http://domain.com/page/עברית'); 

不为我工作。

+0

什么错误说?你有没有试过utf8_encode? – Jonast92 2013-03-17 23:13:00

+0

对希伯来字符进行URL编码可能工作 – ajreal 2013-03-17 23:14:50

+0

该URL在浏览器中不起作用 – MatRt 2013-03-17 23:14:52

回答

0

网址不能包含UTF-8字符。他们必须先进行网址编码。它们可能会在浏览器中显示为UTF-8字符,但这只是您的浏览器使它看起来更漂亮。

When a new URI scheme defines a component that represents textual 
data consisting of characters from the Universal Character Set [UCS], 
the data should first be encoded as octets according to the UTF-8 
character encoding [STD63]; then only those octets that do not 
correspond to characters in the unreserved set should be percent- 
encoded. For example, the character A would be represented as "A", 
the character LATIN CAPITAL LETTER A WITH GRAVE would be represented 
as "%C3%80", and the character KATAKANA LETTER A would be represented 
as "%E3%82%A2". 

http://tools.ietf.org/html/rfc3986#section-2.5

+0

你有一个链接到RFC的地方,它说任何机会? – PeeHaa 2013-03-17 23:18:17

+0

我加了。希望它有助于:) – Evert 2013-03-17 23:31:15

+0

@ evert。谢谢! – PeeHaa 2013-03-17 23:41:55