Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8926021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:51:44+00:00 2026-06-15T07:51:44+00:00

I wanted to read a .reg file exported from windows registry. And I found

  • 0

I wanted to read a .reg file exported from windows registry. And I found that .reg file is encoded as a Windows UNICODE file ( which I think it’s UCS2-LE encoded, because first two bytes are : FFFE ).

So I read file as this:

fp = _wfopen(lpszRegFilePath, _T("r, ccs=UNICODE"));
if ( NULL == fp)
{
    dwErr = ERROR_NOT_FOUND;
    break;
}
szData = new WCHAR[8192];
ZeroMemory(szData, 8192);

fgetws(szData, 8192, fp);
//........

here is the szData result:
enter image description here

can _wfopen recognize BOM ? if so why it just ignore the FFFE BOM ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:51:45+00:00Added an answer on June 15, 2026 at 7:51 am

    The "css" parameter allows _wfopen() to detect BOMs and mark the FILE* according so it decodes the rest of the file correctly (if a BOM is present, it overrides the "css" value), but it does not discard the BOM, and there is nothing in the documentation to say it does. So you will just have to check the first 2 WCHARs read from the file to see if they are the UTF-16LE BOM (a UTF-8 BOM would get decoded into a UTF-16LE BOM) and ignore them if needed.

    Update: something just occurred to me. fgetws() is returning the individual bytes of the BOM as individual WCHAR values in your buffer. It should not be doing that if it is respecting the BOM, which means it is parsing the file as Ansi/MBCS and not as UTF-16LE. Are you using Visual C++? The "css" parameter is a VC++-specific extension to _wfopen(). Non-Microsoft compiler vendor do not support it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wanted to know which is the best way to read a file that
I am new to Python and wanted to read a file, which has even
I need to un-read characters from an InputStreamReader . For that purpose I wanted
I am trying to read the file 'train-images-idx3-ubyte', which can be found here along
I wanted read event viewer log file using event ID in Windows 7
I wanted to read bytes from file and then rewrite them. I did like
I was developing a antimalware, and wanted to read Signature from a Signature.txt file,
Suppose that I wanted to read an integer from cin and then make it
I wanted to read version information of my application from the plit file. For
I downloaded a WavFile package from http://www.labbookpages.co.uk/audio/javaWavFiles.html Using which i wanted to read the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.