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.