0

wstringでタブ文字の位置を見つけようとしています。

しかし、それは私にはうまくいきません。

    int n = wline.find(L"\t");

n は -1 ですが、wstring にタブ文字があることは確かです。

誰かが私のエラーを見ますか? L"\t" が正しくないのではないかと思っていたのですが、L を削除するとコンパイルできなくなりました。

編集:コード全体を投稿しています。おそらく問題は別の場所にあります:

void clsCharacterTranslations::LoadSerializedCharacters(string file)
{

FILE* inFile =  fopen(file.c_str(), "rb");

wchar_t signature[2];
fread(signature, sizeof(wchar_t), 1, inFile);

wstring wline;

while (GetLineW(inFile, wline))
{
    udtCharacterTranslation st;

    int b = 0;
    int n = wline.find(L"\t");
    wstring ws1 = wline.substr(0,n-b);

    b = n+1;
    n = wline.find(L"\t",b);
    wstring ws2 = wline.substr(b,n-b);

    st.Text = ws1;
    st.Translation = ws1;

    m_content.push_back(st);
}

fclose(inFile);

}

bool GetLineW(FILE *inFile, wstring &result)
{
wchar_t data[2]={0,0};

result = L"";
do{
    fread(data, sizeof(wchar_t), 1, inFile);

    if (data[0]>=L' ')
        result += data;

    if (data[0]==0x0A)
        break;
}while(!feof(inFile));

if (result.size()>0)
    return true;
else
    return false;
}

テキスト ファイルが Windows の "Unicode" 形式であるため、void の先頭にある最初の 2 文字を読み取っています。

ありがとうございました!

4

0 に答える 0