在php中读取unicode文件

How to read Unicode file in php.

I have used file_get_contents() function, but after reading file content, I am getting content in decode format(not readable format)

Please provide me your suggestions.

Thanks

-Pravin

You can use iconv to transform your unicode string to any other encoding.

Since you tagged this unicode decode/encode, try running the content you got from file_get_contents through

  • utf8_encode — Encodes an ISO-8859-1 string to UTF-8
  • utf8_decode — Converts a string with ISO-8859-1 characters encoded with UTF-8 to single-byte ISO-8859-1

If your file content is not ISO-8859-1, consider Elzo's answer to use iconv.