Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: String literals are misinterpreted by the Visual C++ compiler in Visual Studio 2010 when the string literals use UTF-8 encoding and contain Asian characters


View products that this article applies to.


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

↑ Back to the top


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.

↑ Back to the top


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. 

↑ Back to the top


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:Note 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 nameFile versionFile sizeDateTimePlatform
C1.dll16.0.30319.351658,24023-Aug-201006:45x86
C1.dll16.0.30319.351723,77623-Aug-201006:45x86
C1.dll16.0.30319.351899,40023-Aug-201006:45x86
C1xx.dll16.0.30319.3512,286,92023-Aug-201006:45x86
C1xx.dll16.0.30319.3512,428,23223-Aug-201006:45x86
C1xx.dll16.0.30319.3512,659,66423-Aug-201006:45x86
Clui.dll16.0.30319.351201,03223-Aug-201006:45x86
Clui.dll16.0.30319.351202,56823-Aug-201006:45x86
Clui.dll16.0.30319.351219,97623-Aug-201006:45x86
Clui.dll16.0.30319.351221,00023-Aug-201006:45x86
Clui.dll16.0.30319.351290,63223-Aug-201006:45x86
Clui.dll16.0.30319.351291,65623-Aug-201006:45x86
Clui.dll16.0.30319.351292,68023-Aug-201006:45x86
Clui.dll16.0.30319.351293,70423-Aug-201006:45x86
Clui.dll16.0.30319.351408,39223-Aug-201006:45x86
Clui.dll16.0.30319.351408,90423-Aug-201006:45x86
Clui.dll16.0.30319.351450,37623-Aug-201006:45x86
Clui.dll16.0.30319.351460,10423-Aug-201006:45x86
Clui.dll16.0.30319.351460,61623-Aug-201006:45x86
Clui.dll16.0.30319.351478,02423-Aug-201006:45x86
Clui.dll16.0.30319.351478,53623-Aug-201006:45x86
Clui.dll16.0.30319.351483,65623-Aug-201006:45x86
Clui.dll16.0.30319.351484,16823-Aug-201006:45x86
Clui.dll16.0.30319.351486,72823-Aug-201006:45x86
Clui.dll16.0.30319.351487,24023-Aug-201006:45x86
Clui.dll16.0.30319.351491,84823-Aug-201006:45x86
Clui.dll16.0.30319.351492,36023-Aug-201006:45x86

↑ Back to the top


Status

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

↑ Back to the top


Keywords: kbqfe, kbhotfixserver, kbfix, kbnotautohotfix, kbsurveynew, kbprb, kbbug, kbexpertiseinter, kb

↑ Back to the top

Article Info
Article ID : 2284668
Revision : 2
Created on : 9/21/2018
Published on : 9/21/2018
Exists online : False
Views : 544