Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1060

How to read UTF-8 file data in C++?

$
0
0

I have a list of IPA (UTF-8) symbols in a text file called ipa.txt with numbers assigned to them. How do I cross reference it with a source file which is also a text file that contains a bunch of words and their corresponding IPA, to return a text file for every names with their names as their filename and inside the text file should contain their corresponding numbers of IPA.

Below is what I've tried but didn't work, only outputs were mostly 000000.

int main(){    std::unordered_map <wchar_t, int> map;    std::wifstream file;    file.open("ipa.txt");    if (file.is_open()) {        std::cout << "opened ipa file";    }    wchar_t from;    int to;    while (file >> from >> to) {        map.insert(std::make_pair(from, to));    }    std::wifstream outfile;    outfile.open("source.txt");    if (outfile.is_open()) {        std::cout << "opened source file";    }    std::wstring id;    std::wstring name;    while (outfile >> id >> name) {        std::ofstream outputfile;        outputfile.open(id + L".txt");        for (wchar_t c : name)  outputfile << map[c];     }    system("pause");    return 0;}

Viewing all articles
Browse latest Browse all 1060

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>