How can I read a text file containing Unicode, into a wchar_t pointer using wifstream?
问题 I'm trying to read Unicode characters from a text file into a wchar_t pointer array, using wifstream . Here is a code snippet: locale::global(std::locale("en_US.UTF-8")); std::wifstream inputFile("gsmCharacterSet.txt", std::ifstream::binary | std::ifstream::ate); int length = inputFile.tellg(); inputFile.seekg(0,inputFile.beg); wchar_t *charArray = new wchar_t[length]; inputFile.read(charArray,length); It's not working. The length returned is 252 which is the correct file size in bytes.