Use php to read TXT data (words, phonetic symbols, and translations) to another TXT file. What are the causes of garbled characters?

Source: Internet
Author: User
Using php to read the TXT file data (words, phonetic symbols, and translations) to another TXT file, garbled characters appear. why? Using php to read the TXT file data (words, phonetic symbols, and translations) to another TXT file, garbled characters appear. why? Php uses php to read the TXT file data (words, phonetic symbols, and translations) to another TXT file. what is the cause of garbled characters?
Using php to read the TXT file data (words, phonetic symbols, and translations) to another TXT file, garbled characters appear. why?

Php

Share:


------ Solution --------------------
Of course, the encoding is inconsistent.
------ Solution --------------------
Reference:
How can this problem be solved?

Quote: reference:

Of course, the encoding is inconsistent.


Encoding conversion
Http://www.baidu.com? Wd = PHP + % B1 % E0 % C2 % EB % D7 % AA % BB
------ Solution --------------------
First look at the file encoding such as UTF-8
Let's look at the encoding of file B, such as GB1312.
First $ text = fget ($ fpa)
Then $ text = iconv ('utf-8', 'gbk', $ text)
Write file B again
------ Solution --------------------
What is read, write and get.
No encoding issues, unless your code is faulty
You can give test data and code

------ Solution --------------------
There are both phonetic symbols and translation, do not think, it is certainly unicode, but unicode is just a name, the specific is UTF-8, UTF-16, UC2 ...... You still need to make your own judgment to keep the encoding of the original txt, output txt, and php programs consistent.

Use "rb" for reading, "wb" for writing, and echo for intermediate conversion format. if The echo result is correct, the output is basically OK.
------ Solution --------------------
Paste the code.

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.