Are resource files compiled as UNICODE or ANSI code-page?

為{幸葍}努か 提交于 2019-12-10 02:04:30

问题


First - my apologies if this has been answered a hundred times over! D'oh!

But my search-fu apparently sucks, as I'm having no luck answering this basic question:

How are resources stored in the EXE/DLL? As UNICODE (UCS-2, Windows native internal character format), or as multibyte characters using the code-page of the resources block?

  • How does one embed UNICODE strings into one's resources (.rc)?
  • Can UNICODE (UCS-2) text be inserted into the language strings from within VS 2012?
  • Is Windows still using UCS-2, or is it using UTF16 internally?

I'm just looking for general answers, or links to details, rather than a detailed how-to for putting a UNICODE string into an .rc string table. Thanks!


回答1:


All resource strings in WIN32 are compiled as Unicode. See here for more info. The .rc script itself can be ANSI (using the local codepage) or UCS-2 with the appropriate BOM (reference).




回答2:


If in doubt take a look at the hex. Here the start of notepad.exe's rc file, in UTF16:

0002ed60  01 00 53 00 74 00 72 00  69 00 6e 00 67 00 46 00  |..S.t.r.i.n.g.F.|
0002ed70  69 00 6c 00 65 00 49 00  6e 00 66 00 6f 00 00 00  |i.l.e.I.n.f.o...|
0002ed80  a6 02 00 00 01 00 30 00  34 00 30 00 39 00 30 00  |......0.4.0.9.0.|
0002ed90  34 00 42 00 30 00 00 00  4c 00 16 00 01 00 43 00  |4.B.0...L.....C.|
0002eda0  6f 00 6d 00 70 00 61 00  6e 00 79 00 4e 00 61 00  |o.m.p.a.n.y.N.a.|
0002edb0  6d 00 65 00 00 00 00 00  4d 00 69 00 63 00 72 00  |m.e.....M.i.c.r.|
0002edc0  6f 00 73 00 6f 00 66 00  74 00 20 00 43 00 6f 00  |o.s.o.f.t. .C.o.|
0002edd0  72 00 70 00 6f 00 72 00  61 00 74 00 69 00 6f 00  |r.p.o.r.a.t.i.o.|


来源:https://stackoverflow.com/questions/12692803/are-resource-files-compiled-as-unicode-or-ansi-code-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!