/ / file_get_contentsをヘブライ文字列で使用する - PHP、URL、文字エンコーディング、ヘブライ

ヘブライ文字列でfile_get_contentsを使用する - PHP、URL、文字エンコーディング、ヘブライ語

私は助けが必要です file_get_contents() 関数。

いくつかのヘブライ文字を含むURLからデータを取得しようとすると、ホストからエラーが発生します(リンクが無効です)。

例えば:

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

私のために働かない。

回答:

回答№1は0

Urlはutf-8文字を含むことはできません。最初にURLエンコードする必要があります。彼らはあなたのブラウザに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