Wonder if anyone could help on this issue?
As we know .txt files encoded with UTF-8 and Unicode(UTF-16) have hidden characters.
I am writing a program that takes a selected .txt file with different encoding UTF-8, and Unicode(UTF-16). I need get the first character of the string and store it. What I need to do with that string is take it and put it into a separate string and use std::stoi to get the int value of the hidden character.
//OPEN THE FILE IN BINARY
std::fstream mazeFile(mazeFileLoc, std::ios::in | std::ios::binary);
if (mazeFile.is_open())
{
//STORE THE FIRST CHARACTER AS AN CHAR VALUE
char test = mazeFile.get();
std::cout << "First Character is : " << test << std::endl;
//PUT THE CHAR VALUE IN A STRING
std::string strTest;
strTest.insert(strTest.begin(), test);
std::cout << "String First Character is : " << strTest << std::endl;
//USE STOI TO GET THE INT VALUE OF STRING
int testIntVal = std::stoi(strTest);
std::cout << "Int Value of first character is : " << testIntVal << std::endl;
mazeFile.close();
}
The issue that I am having is it is flagging an error during run time when I use stoi.
Does anyone know why this may be flagging an error and not converting it?
Git Link : https://github.com/xSwalshx/ANN.git