3

I have a .rc file with the following entry:

01111 my_res { "string 1" }
01113 my_res { "string 2" }
01119 my_res { "string 3" }

When I compile this .rc file with rc.exe, the resource entry id become 1111, 1113 and 1119 respectively.

Apparently, the resource compiler treated the ID as numerics.

My first impression was the .res files can't store numeric as string type. But when use a resource editor (e.g.: XNResourceEditor.exe to change the resource ID 1111 to 01111 and it stored as 01111. This shows that the resource id may store numeric as string type.

Is there a way to compile numeric resource id as string type?

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Chau Chee Yang
  • 18,422
  • 16
  • 68
  • 132
  • Can you show you an entire resource script. We are missing a lot of context here. For instance, we don't know what `my_res` is. Obviously don't show your entire script, cut it down first. – David Heffernan Feb 10 '15 at 09:47
  • @DavidHeffernan: That is my cut down version of rc file. I have only one type of resource. – Chau Chee Yang Feb 10 '15 at 09:49
  • It doesn't compile when I use brcc32. I assume that resource compiler since the question is tagged delphi. If you mean to use rc, then the delphi tag is wrongly applied. – David Heffernan Feb 10 '15 at 09:50
  • @DavidHeffernan: Go to `Project | Options` and change the resource compiler to `Windows SDK Resource Compiler`. Don't use `Borland Resource Compiler (brcc32.exe)`, it will show errors. – Chau Chee Yang Feb 10 '15 at 09:54
  • I've re-tagged the question. It's not a Delphi question, it's a question about the MS resource compiler RC. – David Heffernan Feb 10 '15 at 09:55
  • @sashaolm Thanks for adding that tag, rc.exe, but that's a tag with only two questions. That tag should be removed. A better tag is rc. – David Heffernan Feb 10 '15 at 10:09
  • Out of interest, did you try putting the IDs in quotes? – Jonathan Potter Feb 10 '15 at 10:42
  • @JonathanPotter: I have tried single quote (`'`), double quote (`"`), slash (`/` and `\\`) and none of that works. – Chau Chee Yang Feb 10 '15 at 10:49
  • @ChauCheeYang You should avoid the phrase "none of that works". You can put the ID in quotes. But the quotes appear in the id text when you compile the resource. – David Heffernan Feb 10 '15 at 11:29

1 Answers1

3

The resource compiler RC does not have any syntax that allows you to escape an integer ID so that it is treated as text.

The documentation says:

Unique name or a 16-bit unsigned integer that identifies the resource.

The resource compiler attempts to interpret the ID as an integer. If it can do so then the ID is interpreted as an integer, otherwise it is interpreted as a string. If the integer exceeds the bounds of a 16 bit integer, then its value and 0xffff is used.

This is a limitation of the resource compiler. The resource format supports text IDs that only contain digits. If it is crucial for you to produce such resources then I think you would need to either:

  1. Find a resource compiler that does allow numbers to be escaped as text, or
  2. Write your own basic resource compiler to perform the task.
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490