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

  • Home
  • SEARCH
  • 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 8596047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:35:04+00:00 2026-06-12T00:35:04+00:00

Code points of some Unicode characters (like ) consume more than 2-bytes. How do

  • 0

Code points of some Unicode characters (like ) consume more than 2-bytes. How do I use Win32 API functions like CreateFile() with these characters?

WinBase.h

WINBASEAPI
__out
HANDLE
WINAPI
CreateFileA(
    __in     LPCSTR lpFileName,
    __in     DWORD dwDesiredAccess,
    __in     DWORD dwShareMode,
    __in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
    __in     DWORD dwCreationDisposition,
    __in     DWORD dwFlagsAndAttributes,
    __in_opt HANDLE hTemplateFile
    );
WINBASEAPI
__out
HANDLE
WINAPI
CreateFileW(
    __in     LPCWSTR lpFileName,
    __in     DWORD dwDesiredAccess,
    __in     DWORD dwShareMode,
    __in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
    __in     DWORD dwCreationDisposition,
    __in     DWORD dwFlagsAndAttributes,
    __in_opt HANDLE hTemplateFile
    );
#ifdef UNICODE
#define CreateFile  CreateFileW
#else
#define CreateFile  CreateFileA
#endif // !UNICODE

LPCSTR and LPCWSTR are define in WinNT.h as:

typedef __nullterminated CONST CHAR *LPCSTR, *PCSTR;
typedef __nullterminated CONST WCHAR *LPCWSTR, *PCWSTR;

CHAR and WCHAR is defined in WinNT.h as:

typedef char CHAR;
#ifndef _MAC
typedef wchar_t WCHAR;    // wc,   16-bit UNICODE character
#else
// some Macintosh compilers don't define wchar_t in a convenient location, or define it as a char
typedef unsigned short WCHAR;    // wc,   16-bit UNICODE character
#endif

CreateFileA() accepts LPCSTR file names, which are stored in 8-bit char array internally.
CreateFileW() accepts LPCWSTR file names, which are stored in 16-bit wchar_t array internally.

I have created a file in the position C:\.txt. It looks like it is not possible to open this file using CreateFile(), because it contains the character whose Unicode code point is 0x24B62 which doesn’t fit even in a WCHAR array cell.

But that file exists in my harddisk and Windows manages it normally. How do I open this file by a Win32 API function, like Windows does internally?

  • 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-12T00:35:06+00:00Added an answer on June 12, 2026 at 12:35 am

    Such characters are represented by UTF-16 surrogate pairs. It takes two wide character elements to represent that code point. So, you just need to call CreateFile passing the necessary surrogate pair. And naturally you need to use the wide variant of CreateFile.

    Presumably you won’t be hard-coding such a filename in your code. In which case you’ll be getting it from a file dialog, FindFirstFile, etc. And those APIs will give you the appropriate UTF-16 encoded buffer for the file.

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

Sidebar

Related Questions

The unicode standard has enough code-points in it that you need 4 bytes to
I'd like to add Unicode characters to plain text email being sent via SMTP.
I can see some duplicate characters in Unicode . For example, the character 'C'
I obtain some text from Internet. There are sometimes characters like &a m p;,
Some characters such as the Unicode Character 'LATIN SMALL LETTER C WITH CARON' can
I'd like to iterate through Unicode characters, gobbling up all combining characters that follow
I'm dealing with unicode data characters, and I wonder why some do not have
I have some unicode codepoints (\u5315\u4e03\u58ec\u4e8c\u4e0a\u53b6\u4e4b), which I have to convert into actual characters
I have some C++ code that prints a size_t : size_t a; printf(%lu, a);
I am working with some legacy code, and at some point there is a

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.