C++ の非 Ascii 文字に関するいくつかの問題に直面しています。ファイル処理を介してC++で読み取っている非ASCII文字を含むファイルが1つあります。ファイル(1.txtなど)を読み取った後、データを文字列ストリームに保存し、別のファイル(2.txtなど)に書き込みます。
1.txt に以下が含まれているとします。
ação
2.txt で同じ ouyput を取得する必要がありますが、ASCII 以外の文字は 2.txt の 16 進数値として出力されます。
また、C++ が Ascii 文字を Ascii のみとして処理していることは確かです。
2.txt でこれらの文字を正しく印刷する方法についてヘルプをください
編集:
まず、プロセス全体の疑似コード:
1.Shell script to Read from DB one Value and stores in 11.txt
2.CPP Code(a.cpp) reading 11.txt and Writing to f.txt
読み取り中の DB に存在するデータ:Instalação
ファイル 11.txt には以下が含まれます。Instalação
ファイル F.txt の内容:Instalação
画面上の a.cpp の出力:Instalação
a.cpp
#include <iterator>
#include <iostream>
#include <algorithm>
#include <sstream>
#include<fstream>
#include <iomanip>
using namespace std;
int main()
{
ifstream myReadFile;
ofstream f2;
myReadFile.open("11.txt");
f2.open("f2.txt");
string output;
if (myReadFile.is_open())
{
while (!myReadFile.eof())
{
myReadFile >> output;
//cout<<output;
cout<<"\n";
std::stringstream tempDummyLineItem;
tempDummyLineItem <<output;
cout<<tempDummyLineItem.str();
f2<<tempDummyLineItem.str();
}
}
myReadFile.close();
return 0;
}
ロケールはこれを言います:
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=