The problem is:
1. Use fstream to read Chinese files in Linux and store them in the string class.
2. Search, insert, replace, and append a string.
3. Use the SMTP protocol to send emails using the processed string.
4. The windows machine uses outlook to receive emails and finds several garbled characters in the body.
Continue to test the string class:
String text;
For (INT I = 0; I {
Text. append ("I ");
}
Sendmail (text );
Emails received by outlook on Windows machines are as follows:
Please refer to the following link for more information: please refer to the following link for more information: please refer to the following link for more information: please refer to the following link for more information: please refer to the following link for more information: please refer to the following link for more information: please refer to the following link for more information: please refer to the following link for more information: please refer to the following link for more information: please refer to the following link for more information: please refer to the following link for more information: please refer to the following link for more information: when there are too many threads, there are too many threads, too many threads
Please refer to the following link for more information: please refer to the following link for more information: please refer to the following link for more information: when there are too many threads, there are too many threads, too many threads
It can be seen that there is a sudden line break in the middle. It may be that the string in Linux is not compatible with the Linux Encoding Process (or the Windows line feed is/R/N, and Linux is/N ). Run string. when append () is used, if the string class finds that the space is insufficient, it will request a larger memory to the operating system, copy the content to the new memory, and release the original memory, leading to garbled characters.
Solution:
1. Use notepad in Windows to edit the file content and save it as UTF-8 encoding format
2. upload files to Linux machines using Samba sharing
3. Read the file content into the cache using C in Linux. char *
4. Search, insert, replace, and append char * in the cache.
5. Convert the processed char * cache to the string class (string context (char *) and use the SMTP protocol to send emails (Sendmail (context ))
6. Windows machines use outlook to receive emails, and no garbled characters are found in the Chinese text.