`
javasogo
  • 浏览: 1773427 次
  • 性别: 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 ...

    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-...

    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...

    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 ...

    Electronics A Systems Approach 6th Edition by Neil Storey- 2017

    If the number of the exercise is set in italic type, for example, see Exercise 1.11, on page 14, this indicates that the answer can be found in this appendix. Circuit simulation Throughout the book ...

    Start Here! Learn the Kinect API

    this book explores the fundamentals of the signals being processed: how video, audio, depth, and 3D skeleton information can be represented in a program. Also included is coverage of specific ...

    Graph-based Natural Language Processing and Information Retrieval

    There is hardly any domain in which objects and their relations cannot be intuitively represented as nodes and edges in a graph. Graph theory is a well-studied sub-discipline of mathematics, with a ...

    remote_node_table.rar_The Count

    This is a count of the numeber of remote nodes that can be represented in a byte.

    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 ...

    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 ...

    PHP and MySQL Web Devepopment 4th Edition.pdf

    The /E switch is similar to the /A switch, except that instead of telling DCDIAG to test all of the domain controllers in the current site, it tells DCDIAG to test every domain controller in the ...

    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...

    android dex format

    android dex Dalvik VM Instruction Formats

    Geometric Optics_ Theory and Design of Astronomical Optical Systems Using mma

    third class contains books that approach the subject in a manner that is intermediate between the first two classes (see, for instance, [15–21]). The aim of this book, which could be placed in the ...

    Python_Real-World+Data+Science_A+Course+in+Four+Modules-2016.pdf

    When we write code, we're instructing a computer on what are the things it has to do. Where does the action happen? In many places: the computer memory, hard drives, network cables, CPU, and so on. ...

Global site tag (gtag.js) - Google Analytics