Ask a question about fopen.

Source: Internet
Author: User
Could you tell me a fopen problem? I used fopen to open a file, but the file path contains Japanese characters, so that the file cannot be found. How can this problem be solved? Thank you! ------ Solution ------------------ change the file name to English ------ solution -------------------- I have encountered this problem before. then I changed the file name to English, I have never encountered this problem again. ------ Could you tell me a question about fopen?
I use fopen to open a file, but the file path contains Japanese characters, so that the file cannot be found. How can this problem be solved? Thank you!
------ Solution --------------------
Change the file name to English.
------ Solution --------------------
I have encountered this problem before. After I changed the file name to English, I never encountered this problem again.
------ Solution --------------------

$ Path = '{}.txt ';
$ Fp = fopen ($ path, "r ");
$ F = fread ($ fp, filesize ($ path ));
Echo $ f;
Fclose ($ fp );

It is tested that there is no problem in Windows and linux (centos.

Check whether the file path is correct.
------ Solution --------------------
The encoding may be different. for example, the English system may use unicode encoding.
The real Japanese system may be Japanese-coded, such as shift-jis.
In fact, just use the mt encoding conversion function to convert it. just try it several times.
To read a file, you must use the system encoding. Therefore, the string must be converted from the PHP file encoding to the system encoding.
------ Solution --------------------
Can you create a new Japanese file name in English version 2012?
------ Solution --------------------
Try to recreate this file in the English version.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.