Using php to read the TXT file data (words, phonetic symbols, and translations) to another TXT file, garbled characters appear. why? Php
Using php to read the TXT file data (words, phonetic symbols, and translations) to another TXT file, garbled characters appear. why?
Reply to discussion (solution)
Of course, the encoding is inconsistent.
How can this problem be solved?
Of course, the encoding is inconsistent.
How can this problem be solved?
Of course, the encoding is inconsistent.
Encoding conversion
Http://www.baidu.com? Wd = PHP + % B1 % E0 % C2 % EB % D7 % AA % BB
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
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
The two files are encoded in the same way. I want to split the single-byte phoneme and translation, and then write it into B .txt in a specific format. Both files are Lucida Sans Unicode. Is there a problem with my php code?
What is read, write and get.
No encoding issues, unless your code is faulty
You can give test data and code
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.
Paste the code.
File encoding (utf8, ansi) format must be consistent