`
javasogo
  • 浏览: 1833218 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

The file contains a character that cannot be represented in the current code page (936)

 
阅读更多

1. 方法一:将文件中的乱码找到去掉


用VS2005+DirectX9 SDK(手头测试过的是2004年10月的DirectX SDK和2006年4月的DirectX SDK)编译游戏会出现以下warning:

--------------------------------------------------------------------------------

d:\microsoft directx 9.0 sdk (october 2004)\include\d3d9types.h(1385) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss

--------------------------------------------------------------------------------
要修正这个问题,不必要存为UTF8的文件,而是搜索_D3DDEVINFO_VCACHE,然后会看到:

typedef struct _D3DDEVINFO_VCACHE ...{
DWORD Pattern; /**//* bit pattern, return value must be FOUR_CC(慍? 慉? 慍? 慔? */
DWORD OptMethod; /**//* optimization method 0 means longest strips, 1 means vertex cache based */
DWORD CacheSize; /**//* cache size to optimize for (only required if type is 1) */
DWORD MagicNumber; /**//* used to determine when to restart strips (only required if type is 1)*/
} D3DDEVINFO_VCACHE, *LPD3DDEVINFO_VCACHE;
那四个乱码的去掉就可以了


2.方法二: 将该文件存为 UTF-8 文件

(折腾了很久,记录一下)


3. 与此相关的其他信息

其实这是个警告,你可以修改编译选项,不要把警告看做error!
这虽然只是一个警告,但是会导致不能进行DEBUG,断点处无法停止。


To get rid of the second warning(C4819) you need to save the file in Unicode format.

Go to file->advanced save options and under that select the new encoding you want to save it as. UTF-8 or UNICODE codepage 1200 are the settings you want.



11 down voteaccepted

Encoding in C++ is quite a bit complicated. Here is my understanding of it.

Every implementation has to support characters from the basic source character set. These include common characters listed in2.2/1. These characters should all fit into one char. In addition implementations have to support a way to name other characters using a way calleduniversal character names and look like \uffff or \Uffffffff and can be used to refer to unicode characters. A subset of them are usable in identifiers (listed in Annex E).

This is all nice, but the mapping from characters in the file, to source characters (used at compile time) is implementation defined. This constitutes the encoding used. Here is what it says literally:

Physical source file characters are mapped, in an implementation-defined manner, to the basic source character set (introducing new-line characters for end-of-line indicators) if necessary. Trigraph sequences (2.3) are replaced by corresponding single-character internal representations. Any source file character not in the basic source character set (2.2) is replaced by the universal-character-name that des- ignates that character. (An implementation may use any internal encoding, so long as an actual extended character encountered in the source file, and the same extended character expressed in the source file as a universal-character-name (i.e. using the \uXXXX notation), are handled equivalently.)

For gcc, you can change it using the option -finput-charset=charset. Additionally, you can change the execution character used to represet values at runtime. The proper option for this is-fexec-charset=charset for char (it defaults to utf-8) and-fwide-exec-charset=charset (which defaults to either utf-16 orutf-32 depending on the size of wchar_t).



The C++ standard doesn't say anything about source-code file encoding, so far as I know.

The usual encoding is (or used to be) 7-bit ASCII -- some compilers (Borland's, for instance) would balk at ASCII characters that used the high-bit. There's no technical reason that Unicode characters can't be used, if your compiler and editor accept them -- most modern Linux-based tools, and many of the better Windows-based editors, handle UTF-8 encoding with no problem, though I'm not sure that Microsoft's compiler will.

EDIT: It looks like Microsoft's compilers will accept Unicode-encoded files, but will sometimes produce errors on 8-bit ASCII too:

warning C4819: The file contains a character that cannot be represented
in the current code page (932). Save the file in Unicode format to prevent
data loss.


warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss



分享到:
评论

相关推荐

    微软内部资料-SQL性能优化2

    Assuming the page reference does not result in an access violation, a page fault can be either hard or soft. A hard page fault results in a read from disk, either a page file or memory-mapped file. A...

    a project model for the FreeBSD Project.7z

    This, combined with the vast amount of dependencies in the kernel and that it is not easy to see all the consequences of a kernel change, demands developers with a relative full understanding of the ...

    Searching For Hidden Messages.pdf

    inspection to detect whether a file contains a message hidden by a specific steganography algorithm. These approaches are very fragile – trivial changes in a steganography algorithm will often render...

    VS_2005下DirectShow开发环境的配置

    1. **编码格式问题:** 在编译过程中可能会遇到警告,比如`The file contains a character that cannot be represented in the current code page (936)。` 这是因为文件编码格式与当前系统默认的编码格式不匹配。...

    i-vector的工具箱

    This toolbox contains a collection of Matlab tools and routines that can be used for research and development in speaker recognition. It provides researchers with a test bed for developing new front-...

    Senfore_DragDrop_v4.1

    * Asynchronous targets appears to be broken in the current release. * When TDropFileTarget.GetDataOnEnter is set to True, the component doesn't work with WinZip. Although the file names are ...

    kgb档案压缩console版+源码

    it contains in human-readable format, followed by the compressed data. The first line of the header is "PAQ6 -m" where -m is the memory option. The data is compressed as if all the files were ...

    Common warehouse metamodel

    information represented in a computer system; e.g. in the form of files, databases, running program instances and so on. Alternatively, the information may be embodied in some system, with the ...

    TMS320C6000 Assembly Language Tools User Guider

    An object module is a file that contains the compiled or assembled code and associated information such as symbol tables. The TMS320C6000 assembler and linker handle sections differently: 1. **...

    Hidden Markov Models Fundamentals

    For instance, we might be interested in discovering the sequence of words that someone spoke based on an audio recording of their speech. Or we might be interested in annotating a sequence of words ...

    华南理工大学计算机全英班编译原理实验1

    Illegal character, that is, scanner may recognize a character that is not in the alphabet of TINY+, such as $ is an illegal character The right bracket of a STRING is lost, such as ' scanner The...

    OTA COM Type Library

    A dependency usually means that one entity uses the other and cannot function without it. A dependency is modeled by relating one entity to the other entities that it uses. This feature supports ...

    Concepts in Electric Circuits

    **Norton’s Theorem**: Norton’s theorem is similar to Thévenin’s theorem but represents the circuit with a current source (In) in parallel with a resistor (Rn), where In is the short-circuit ...

    iOS Fuondation Framework Reference

    **Overview**: `NSArchiver` is a class that manages the archiving process for objects, allowing them to be serialized to a stream or file. It is commonly used for saving and restoring application state...

    android dex format

    | A | 单个字节编码示例 | | ... | 更复杂的编码示例 | #### 结论 DEX文件是Android应用程序的核心组成部分之一,它不仅定义了应用程序的行为逻辑,还包含了所有必要的元数据。理解DEX文件格式对于开发人员来说...

    Linux Kernel 2.4 Internals

    - The boot sector is a critical component that contains code to load the rest of the operating system into memory. This section explains how the boot sector works and how it interacts with the setup ...

    iOS 7示例——iAdSuite与串联图

    In many of the samples the content is represented by a simple TextViewController view controller that displays some text in a read-only UITextView and runs a timer. The UITextView represents your ...

    华南理工大学计算机全英班算法设计实验

    2)Dynamic Programming is an algorithm design method that can be used when the solution to a problem may be viewed as the result of a sequence of decisions and this algorithm is a very useful technique...

Global site tag (gtag.js) - Google Analytics