For a Microsoft Visual Studio 2008 version of this article, see 980263.

Symptoms

Consider the following scenario:

  • You create a Visual C++ project in Microsoft Visual Studio 2010.

  • A file in the project initializes narrow string literals. These string literals contain Asian characters and are not prefixed with the letter "L."

  • The file was saved by using UTF-8 encoding.


In this scenario, when you compile the project, the string literals are misinterpreted by the compiler. Additionally, you encounter one of the following issues:

  • When the file contains a byte-order mark (BOM), the compile operation succeeds. However, the string literals are still displayed incorrectly in the generated application. Additionally, you may receive the following warning message when you compile the project:

    Warning C4566: Character represented by universal-character-name 'xx’ cannot be represented in the current code page.

  • The compile operation fails. Additionally, you may receive the following error message when you compile the project:

    Error C2078: Too many initializers

  • The compile operation fails. Additionally, you may receive the following warning message when you compile the project:

    Warning C4129:'character' : Unrecognized character escape sequence.


Cause

This problem occurs because the compiler assumes that the literals in the file could be interpreted as the lead byte of MBCS encoding instead of as single-byte Unicode. Because of this problem, the compiler incorrectly translates the file. 

Resolution

To resolve this problem, apply this hotfix to the computer on which you compile the project. Then, save the file together with a byte-order mark and then add the following "pragma" directive just before the string literals in the source file:

#pragma execution_character_set("utf-8")

Note This "pragma" directive sets the translation unit for the source file until this "pragma" directive is replaced by another "pragma" directive.

More information about this hotfix

Hotfix information

A supported hotfix is now available from Microsoft. However, it is intended to correct only the problem that is described in this article. Apply it only to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next that contains this hotfix.

To resolve this problem immediately, contact Microsoft Customer Support Services to obtain the hotfix. For a complete list of Microsoft Customer Support Services telephone numbers and information about support costs, visit the following Microsoft website:

http://support.microsoft.com/contactus/?ws=supportNote In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

Prerequisites

You must have Microsoft Visual Studio 2010 installed to apply this hotfix.

Restart information

You do not have to restart the computer after you apply this hotfix.

File information

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.

File name

File version

File size

Date

Time

Platform

C1.dll

16.0.30319.351

658,240

23-Aug-2010

06:45

x86

C1.dll

16.0.30319.351

723,776

23-Aug-2010

06:45

x86

C1.dll

16.0.30319.351

899,400

23-Aug-2010

06:45

x86

C1xx.dll

16.0.30319.351

2,286,920

23-Aug-2010

06:45

x86

C1xx.dll

16.0.30319.351

2,428,232

23-Aug-2010

06:45

x86

C1xx.dll

16.0.30319.351

2,659,664

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

201,032

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

202,568

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

219,976

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

221,000

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

290,632

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

291,656

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

292,680

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

293,704

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

408,392

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

408,904

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

450,376

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

460,104

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

460,616

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

478,024

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

478,536

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

483,656

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

484,168

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

486,728

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

487,240

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

491,848

23-Aug-2010

06:45

x86

Clui.dll

16.0.30319.351

492,360

23-Aug-2010

06:45

x86

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

What affected your experience?

Thank you for your feedback!

×