Answer the question
In order to leave comments, you need to log in
How to understand the structure of a text file at the encoding level?
Good day
It is necessary to write a program that would translate a text file from MS-DOS CP866 encoding to Windows-1251 encoding.
Nowhere can I find information on how a text file is arranged at the encoding level and how to read encoded characters, there are only encoding tables.
I wrote a program with which I write the code of one character to a binary file, when I open this file in a text editor I don’t get anything intelligible.
program code:
#include
#include
#include
#include
using namespace std;
int main(void)
{
int x=0, y=412;
ofstream out("1.bin",ios::binary|ios::out);
out.write((char*)&y,sizeof y);
out.close();
return 0;
}
How can I extract character codes from a text file?
Answer the question
In order to leave comments, you need to log in
"Nowhere I can find information on how a text file is arranged at the encoding level and how to read encoded characters, there are only encoding tables."
But no way. Encoding in relation to a text file is an external entity.
But you can read the content byte by byte and apply encoding conversion to it.
"How can I extract character codes from a text file?"
Well, N read bytes will provide the code of 1 character for the N-byte encoding of the encoding.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question