Search

ftell returns negative value for UTF-8 files opened with textmode and ccs by Martin Richter

Closed
as Fixed Help for as Fixed

5
0
Sign in
to vote
Type: Bug
ID: 591030
Opened: 8/30/2010 6:16:13 AM
Access Restriction: Public
0
Workaround(s)
2
User(s) can reproduce this bug
Create a file UTF-8 coded with BOM.
Open it with fopen and textmode and ccs=UNICODE.

Use ftell and again fseek wit the returned value.
fseek fails.
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

 

Steps to reproduce

Compile the following sample. It causes an ASSERT if test.txt is a UTF-8 file with BOM.

// test.txt must have a BOM and should be coded in UTF-8
int _tmain()
{
    FILE *file = NULL;
    if (_tfopen_s(&file,_T("Test.txt"),_T("rt") _T(", ccs=UNICODE")))
        return -1;

    TCHAR szBuffer[_MAX_PATH];
    while (_fgetts(szBuffer,_countof(szBuffer),file))
    {
        int iPos = static_cast<int>(ftell(file));
        _tprintf(_T("%d\n"),iPos);
        _ASSERTE(fseek(file,iPos,SEEK_SET)==0);
    }

    fclose(file);
    return 0;
}

Product Language

English

Operating System

Windows 7

Operating System Language

German

Actual results

ftell returns negative value and fseek with this value fails.

Expected results

ftell should return a value that is usable with fseek
File Attachments
File Name Submitted By Submitted On File Size  
TestFtell.zip 9/10/2010 5 KB
ftell.zip 10/20/2010 3 KB
Sign in to post a comment.
Posted by Microsoft on 10/27/2011 at 12:07 PM
Thank you for reporting this issue to Microsoft.

This bug has been fixed, and the fix will appear in the next release of Visual Studio.

Thanks,
Mahmoud Saleh
Windows C++ Team
Posted by MandatoryDefault on 10/20/2010 at 10:45 AM
I reproduced the problem. I've attached a complete project that consistently fails.
Posted by Martin Richter on 9/10/2010 at 1:21 AM
I just added a sample that shows the problem.
Posted by Microsoft on 9/10/2010 at 12:44 AM
We are unable to reproduce the issue with the steps you provided.

Please give us a demo project to demonstrate this issue so that we can conduct further research.

It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 7 days, we will close this issue.

Thanks again for your efforts and we look forward to hearing from you.

Posted by Microsoft on 8/30/2010 at 10:45 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 8/30/2010 at 5:03 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.